Special Note : LocalDateTime for the calculation of the date and time provides a great convenience, in the construction of object/operation/tostring, such as convenience are very convenient.
3 Common Classes :
Java.time.localdatetime;java.time.localdate;java.time.localtime;
Recommended Multi-use LocalDateTime
Common Expressions :
Present: LocalDateTime now = Localdatetime.now ();
Today: localdate day = Localdate.now ();
To create an object from a property :
localdatetime.of (int year, month month, int dayofmonth, int hour, int minute, C6>int Second, int nanoofsecond)
convert each other :
Localdate date == = = = Localdatetime.of (date.getyear () + 1900, Date.getmonth () + 1 New// will lose Nanoofsecond
Component Compatibility :
- MyBatis (mybatis-spring v1.3.0) is not currently supported LocalDateTime
- Json (Com.fasterxml.jackson.core v2.5.4) seems to have no special support, the result of serialization is as follows:
{ "month": "December", "year":, "DayOfMonth": 7, " DayOfWeek ":" Thursday ", " dayofyear ": 341, " Monthvalue ":" Hour ": Ten, "minute": 4, "nano": 228000000, "second": "Chronology": { "id": "ISO", "CalendarType": "iso8601" }}
Therefore, when interacting with the database, it is recommended to use java.util.Date when interacting with the Json
Summary :
In the current case, business calculations suggest using LocalDateTime, which is recommended for conversion to Date outside of business calculations
by the To:
LocalDateTime is a great convenience for the calculation of date and time, and there are many other advantages. Details Java8 (date time) API Guide] (http://www.importnew.com/14140.html
Java8 Date/time (date) Usage Introduction