First understand: Date itself is not formatted, just a number of milliseconds, to be displayed as a certain format must be a string
Https://github.com/ewcmsfree/ewcms/wiki/Help-mongo-java-driver-date
MONGO Java driver Date conversion issues
MONGO save date is a 64-bit number. Java driver will automatically convert to standard time GMT when saving date. such as China in the gmt+8 time zone, save 2012-01-20 00:00:00 to the library, the query results unexpectedly is 2012-01-19 16:00:00 with want results inconsistent. You can find the root cause of the problem in Com.mongodb.util.JSON:
if instanceof =new SimpleDateFormat ("Yyyy-mm-dd ' T ' HH:mm:ss. SSS ' Z '); Format.setcalendar (new GregorianCalendar (new simpletimezone (0, "GMT")); Serialize (new basicdbobject ("$date", Format.format (d)), buf); return ;}
If you find a question, you can do it yourself. Conversion of Completion date: #SimpleDateFormat
New SimpleDateFormat ("Yyyy-mm-dd ' T ' HH:mm:ss. SSS ' Z '); Format.setcalendar ( new GregorianCalendar (new simpletimezone (0, "GMT" ) = Format.parse ("2012-01-20 00:00:00");
Date dates become 2012-01-20 08:00:00+08 that is automatically added 8 hours in the gmt+8 time zone.
Or
Convert Date (GMT) to String (gmt+8)//JDK help us automatically add 8
The MONGO is responsible for turning string (gmt+8) into date (gmt+8)
When taken again, the date (GMT+8) is taken as a string (gmt+8)//mongo will not be responsible for the transfer
Mongdb's Datezone