Home  >  Article  >  Java  >  How to handle specific dates in Java8

How to handle specific dates in Java8

WBOY
WBOYforward
2023-05-19 11:05:42925browse

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete