package com.baifan.formatting;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.time.format.TextStyle;
import java.util.Locale;
/**
* @author: baifan
* @date: 2021/2/8
*/
public class Formatting {
public static void main(String[] args) {
//上海时间
ZonedDateTime zonedDateTime = ZonedDateTime.of(2021, 2, 8, 12, 44, 40, 0, ZoneId.of("Asia/Shanghai"));
String format = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(zonedDateTime);
System.out.println(format);
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT);
String format1 = dateTimeFormatter.format(zonedDateTime);
System.out.println(format1);
String format2 = dateTimeFormatter.withLocale(Locale.CHINA).format(zonedDateTime);
System.out.println(format2);
DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("E yyyy-MM-dd HH:mm");
String format3 = dateTimeFormatter1.format(zonedDateTime);
System.out.println(format3);
LocalDate tomorrow = LocalDate.parse("2021-02-09");
System.out.println("tomorrow:" + tomorrow);
ZonedDateTime now = ZonedDateTime.parse("2021-02-08 12:53:00-0800", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssxx"));
System.out.println("now:" + now);
for (DayOfWeek day : DayOfWeek.values()) {
System.out.println(day.getDisplayName(TextStyle.SHORT, Locale.CHINA));
}
}
}