简体   繁体   English

Java日期DST调整我的日期/时间

[英]Java date DST adjusts my date / time

I have a function that accepts 2 set of dates ( start date , and end date ) that will be used for my match engine 我有一个接受2组日期( start dateend date )的函数,这些日期将用于我的匹配引擎

I have to know if the start_date1 & end_date1 is inside start_date2 & end_date2 我必须知道start_date1end_date1是否在start_date2end_date2内部

Fast forward : I already have the right computation and implementation when I run it in local.. But when I run it in cloud.. This is the result 快进:当我在本地运行时,我已经有了正确的计算和实现。但是当我在云中运行时。这就是结果

Result: 结果:

(DATETIME IN SQL)

input > **start_date1** : Apr 1, 2016  6:00am

input > **end_date1** : Apr 1, 2016 7:00pm

--

(TIMESTAMP IN SQL)

input > **start_date2** : Apr 1, 2016 6:00am

input > **end_date2** : Apr 1, 2016 6:00pm


output : true
--------------

As you can see the output must be false.. I think it is being adjusted by the DST.. Please tell me if there is a way to disregard DST or turn it off or the easiest way to disregard it.. 如您所见,输出必须为假。.我认为它是DST调整的。

BTW, I'm using Java 7.. Thanks! 顺便说一句,我正在使用Java7。谢谢!

It can happen if your local and cloud time zone are different. 如果您的本地和云时区不同,则可能会发生这种情况。 Make sure that the two time zone are the same. 确保两个时区相同。

You can change your time zone with this command : 您可以使用以下命令更改时区:

TimeZone.setDefault(TimeZone.getTimeZone("yourTimeZone"));

You can also choose time zone whithout DST, like "UTC" : 您也可以选择没有DST的时区,例如“ UTC”:

TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM