[Java] Date and time

background

When you usually manipulate date and time data, there are always various conversions, calculations, and so on. Sometimes you need to check if there are problems, and record them here.

Before Java 8

Date time conversion

// 字符串->日期时间
Date date = new SimpleDateFormat("yyyy-MM-dd").parse("2005-06-09"); 
// 日期时间->字符串
String now = new SimpleDateFormat("yyyy年MM月dd日").format(date);

Java8

Java8 date and time

reference

java converts a string into a date format

 

Guess you like

Origin blog.csdn.net/yxz8102/article/details/112237958