Home > Java > Java Tutorial > body text

How to handle specific dates in Java8

WBOY
Release: 2023-05-19 11:05:42
forward
795 people have browsed it

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);
      }
  }
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!