Processing specific dates in Java 8
We create today's date very easily through the static factory method now(), you can also call another useful factory method LocalDate.of ()Create any date. This method needs to pass in the year, month, and day as parameters and returns the corresponding LocalDate instance. The advantage of this method is that it does not make the design mistakes of the old API, such as the year starting from 1900, the month starting from 0, etc.
package com.shxt.demo02; import java.time.LocalDate; public class Demo03 { public static void main(String[] args) { LocalDate date = LocalDate.of(2018,2,6); System.out.println("自定义日期:"+date); } }
The above is the detailed content of How to handle specific dates in Java8. For more information, please follow other related articles on the PHP Chinese website!