LocalDate 与 String 之间的转换

    DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd");
	
	LocalDate today = LocalDate.now();
    String dateStr = today.format(fmt);
    System.out.println("LocalDate转String"+dateStr);

    String str = "2019-08-03";
    LocalDate date = LocalDate.parse(str, fmt);
    System.out.println("String转LocalDate"+date);

LocalDate转String2019-08-15
String转LocalDate2019-08-03

你可能感兴趣的:(个人)