简体   繁体   中英

Extracting TimeZone from Mongo Date

I have a date string of the form: "Fri Jun 20 16:14:00 GMT+0530 2014" As you can see there is TimeZone information in the date (GMT+0530).

But once we store this in MongoDB using mongodb 'date' datatype. I see it is stored in a format like this: '2014-06-20 10:44:00.470Z'

How can i extract the 'original' Time Zone from this date??
(I am using Java for storing/extracting data from mongo)

MongoDB使用的BSON Date数据类型只是1970年1月1日以来的毫秒数的64位整数毫秒。因此,如果要跟踪时间戳记的原始时区,则必须将其分开存储,因为转换时它会丢失Date

MongoDB stores dates in ISO 8601 format. There's no straight forward way to convert to it from the Java date format, but here's a similar question, look at the accepted answer, it should give you a clue on how to do this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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