Today, I met a date problem and saw a new feature of JDK8.
Http://www.ibm.com/developerworks/cn/java/j-lo-jdk8newfeature/index.html
Java has a long history of date and time APIs, and the time, date, and other time-date formatting classes in previous versions of Java 8 have been criticized for their high-thread-safety, heavyweight, and serialization-cost issues. Java 8 absorbs the essence of joda-time and creates an excellent API for Java in a new beginning. The new java.time contains all about clocks, local dates (localdate), local time (localtime), Local date time (LocalDateTime), Time zone (zoneddatetime) and Duration (Duration) classes. The historic date class adds the Toinstant () method for converting Date to a new representation. These new localization time-of-day APIs greatly simplify time-of-day and localized management.
For example, here's a simple application for localdate,localtime:
Localdatelocaldate localdate = Localdate.now (); Get local Date Localdate = Localdate.ofyearday (2014, 200); Get the NO. 200 day of 2014 System.out.println (localdate.tostring ());//output: 2014-07-19localdate = Localdate.of (2014, Month.september, 10); September 10, 2014 System.out.println (localdate.tostring ());//output: 2014-09-10//localtimelocaltime localtime = Localtime.now (); Gets the current time System.out.println (Localtime.tostring ());//output current time LocalTime = Localtime.of (10, 20, 50);//Get 10:20:50 The point in Time System.out.println (Localtime.tostring ());//output: 10:20:50//clock clock clocks = Clock.systemdefaultzone ();// Gets the system default time zone (current instantaneous time) long Millis = Clock.millis ();//
C # project to Java Project 4