简体   繁体   中英

Set Date and Time in Different Field in MongoDB

I am inserting Date Object from Java to Mongodb, mongo ISODate(...) stores Date with Time, my requirement is to Store both in different field.

is this possible ?

note : don't want solution that stores milliseconds instead of date. want to store only date like "2013-06-19" and time like "00:00:00"

if i use String format for this than hard to perform date operation.

您可以将Date对象转换为unix时间戳作为timestamp ,然后将timestamp / 86400存储到字段,将timestamp % 86400到另一个字段。

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