Home  >  Article  >  Java  >  How to use predefined formatting tools to parse or format dates in Java8

How to use predefined formatting tools to parse or format dates in Java8

WBOY
WBOYforward
2023-04-28 19:40:051452browse

How to use predefined formatting tools to parse or format dates in Java 8

package com.shxt.demo02;  
import java.time.LocalDate;  
import java.time.format.DateTimeFormatter;  
public class Demo17 {      
public static void main(String[] args) {          
String dayAfterTommorrow = "20180205";          
LocalDate formatted = LocalDate.parse(dayAfterTommorrow,                  
DateTimeFormatter.BASIC_ISO_DATE);          
System.out.println(dayAfterTommorrow+"  格式化后的日期为:  "+formatted);      
}  
}

The above is the detailed content of How to use predefined formatting tools to parse or format 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