C # project to Java Project 4

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.