You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by "Liubao (A)" <ba...@huawei.com> on 2019/12/16 01:20:30 UTC

答复: [DISCUSS][JavaChassis] Specify a way to generate java.time.Clock

Quoto from Yao Haishi " maybe use Clock.systemDefaultZone() is okay? Users will specify the JVM timezone if necessary."

I think this is the best practice in java. We do not need to set timezone in code, JVM has done it for you and users can customize it following JVM conventions, e.g. using -Duser.timezone or read from system environment like $TZ 

-----邮件原件-----
发件人: Willem Jiang [mailto:willem.jiang@gmail.com] 
发送时间: 2019年12月15日 9:36
收件人: dev <de...@servicecomb.apache.org>
主题: Re: [DISCUSS][JavaChassis] Specify a way to generate java.time.Clock

It think we may provide a way to set the zone by checking the System variable such TZ[1], if we cannot find the variable, we could use the system default as a fallback with some log information.

[1]https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html

Willem Jiang

Twitter: willemjiang
Weibo: 姜宁willem

On Thu, Dec 12, 2019 at 4:51 PM Ang Li <li...@qq.com> wrote:
>
> Hi Team,
> I am currently solving issue 
> [SBC-1559](https://issues.apache.org/jira/browse/SCB-1559). The core idea of this issue is using java.time.Clock instead of&nbsp;java.lang.System#currentTimeMillis to get time for mocking purpose.&nbsp; java.time.Clock provides many different ways to generate a clock. I am wondering which one should we use and do we need to specify a zone?
> Thanks a lot if someone can help.
>
>
> --------------------------------------
> Ang Li