utc

Java Date Conversion - UTC to Local - works differently depending on the timezone

℡╲_俬逩灬. 提交于 2019-12-24 17:04:35
问题 I'm experiencing a problem when converting strings to a UTC data, and then to various timezones. It appears that my program behaves differently depending on whether I convert to EST or PST. Here is my code: SimpleDateFormat utcFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); utcFormat.setTimeZone(java.util.TimeZone.getTimeZone("UTC")); Date date = utcFormat.parse("2014-08-18 17:00:17"); SimpleDateFormat localFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); localFormat.setTimeZone

Confusion in java.Clock, systemDefaultZone() returning UTC time

≯℡__Kan透↙ 提交于 2019-12-24 06:54:09
问题 I am trying to understand why the following java.time.Clock is returning UTC time instead of the local time zone (EST). C:\Users\Felipe>scala Welcome to Scala 2.12.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_65). Type in expressions for evaluation. Or try :help. scala> import java.time._ import java.time._ scala> ZoneId.systemDefault() res0: java.time.ZoneId = America/New_York scala> val clock = Clock.systemDefaultZone() clock: java.time.Clock = SystemClock[America/New_York] scala> clock

Confusion in java.Clock, systemDefaultZone() returning UTC time

假如想象 提交于 2019-12-24 06:53:48
问题 I am trying to understand why the following java.time.Clock is returning UTC time instead of the local time zone (EST). C:\Users\Felipe>scala Welcome to Scala 2.12.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_65). Type in expressions for evaluation. Or try :help. scala> import java.time._ import java.time._ scala> ZoneId.systemDefault() res0: java.time.ZoneId = America/New_York scala> val clock = Clock.systemDefaultZone() clock: java.time.Clock = SystemClock[America/New_York] scala> clock

Get UTC offset in WP7

北城以北 提交于 2019-12-24 06:01:26
问题 Does anyone know the best way to get the UTC offset in WP7? Apparently the TimeZone api hasn't been implemented there. Thanks 回答1: Just use DateTimeOffset.Now.Offset ... that is why DateTimeOffset was created! 回答2: If you just want to convert to local time, use DateTime.ToLocalTime() . If you want the offset, I think you can subtract the original value. Documentation. 回答3: I recently did something like the below; this was done quickly but it works. In my case I always wanted time as of

After loading UTC data, Dygraph axis dates are too long and won't adjust

感情迁移 提交于 2019-12-24 03:42:48
问题 I'm feeding Dygraph some nice unix epoch data, and it's showing the axes like this: I can't get it to be more terse and dynamically adjusted, after much fiddling. Here's my code: var graph = new Dygraph( document.getElementById('plot' + formNum), fileURL, // path to CSV file { legend:'always', title: "Activity of " + station + ".BK." + fullChannel + dateString, valueParser: function(x){ return x*1000; }, ticker: Dygraph.dateTicker } Why are they so long? How can I change them and still take

After loading UTC data, Dygraph axis dates are too long and won't adjust

ⅰ亾dé卋堺 提交于 2019-12-24 03:42:38
问题 I'm feeding Dygraph some nice unix epoch data, and it's showing the axes like this: I can't get it to be more terse and dynamically adjusted, after much fiddling. Here's my code: var graph = new Dygraph( document.getElementById('plot' + formNum), fileURL, // path to CSV file { legend:'always', title: "Activity of " + station + ".BK." + fullChannel + dateString, valueParser: function(x){ return x*1000; }, ticker: Dygraph.dateTicker } Why are they so long? How can I change them and still take

格式化时间

柔情痞子 提交于 2019-12-24 03:20:32
格式化时间 软件中的日期格式化 1.日期格式化就是对日期字符串进行解析和格式化输出 2.在软件系统中,展现层的日期数据为字符串,逻辑层的日期为Date对象,存储层的日期数据为时间戳 3.日期格式化就是在不同层次之间进行数据转换 时间戳 <-> Date对象 <-> 格式化字符串 UTC时间与本地时间的关系 UTC(Universal Time Coordinated)是世界统一时间,GMT(Greenwich MeanTime) 格林尼治时间,UTC 与 GMT 的含义完全相同。 UTC + 时区差 = 本地时间 时区差东为正,西为负 本地时间: Date: Sun, 13 June 2010 09:45:28+0800 UTC时间: 0945 - 0800 = 0145 即UTC是当天凌晨1点45分28秒。 若结果为负就意味着是UTC前一天,把这个负数加上2400就是UTC在前一天的时间 本地时间: 本地(北京)时间是0325 (凌晨3点25分) UTC时间: 0325-0800 = -0475(负号意味着是前一天) -0475+3400 = 1925(前一天的晚上7点25分。) 纽约的时区是西五区,比UTC落后五个小时,记为-0500 UTC + (-0500) = 纽约时间 UTC = 纽约时间 + 0500 UTC = 北京时间 - 0800 = 纽约时间 + 0500

Testing correct timezone handling

删除回忆录丶 提交于 2019-12-23 09:10:06
问题 We are working with large amounts of data, all tagged in UTC (in Java). Between reading this data, storing it in a database and getting it out again, it happened, that some data was off one hour during daylight saving time. As UTC has no concept of daylight saving time this was clearly a bug within the software. Once known, it's easy to fix. However, it'd be nice to have some unit/integration tests that work regardless of the current time difference - e.g. I'd like to change the local time

Why was Date.getTimezoneOffset deprecated?

时光怂恿深爱的人放手 提交于 2019-12-23 07:35:24
问题 The documentation for Date.getTimezoneOffset says: Deprecated. As of JDK version 1.1, replaced by -(Calendar.get(Calendar.ZONE_OFFSET) + Calendar.get(Calendar.DST_OFFSET)) / (60 * 1000). Why was it deprecated? Is there a shorter way (Apache Commons?) to get the offset from UTC in hours/minutes? I have a Date object ... should I convert it to JodaDate for this? And before you ask why I want the UTC offset - it's just to log it, nothing more. 回答1: There are 2 questions here. Why was Date

Date and time handling in applications serving clients in multiple time-zones?

本小妞迷上赌 提交于 2019-12-23 05:17:17
问题 The internationalization problems associated with string handling can pretty much be solved by following the advice: use Unicode and store everything as UTF-8 in your database, then you'll be able to serve clients using all the world's languages. But what about the internationalization problems associated with date/time handling? Questions: Are there similar easy-to-follow best practices for solving the internationalization issues surrounding time handling? How do you make sure your