zoukankan      html  css  js  c++  java
  • jdk8 日期格式转换"yyyyMM"

    LocalDate必须有年,月,日三个内容

            //LocalDate -> YearMonth -> String
            LocalDate localDate = LocalDate.now();
            YearMonth yearMonth = YearMonth.of(localDate.getYear(), localDate.getMonthValue());
            String str = yearMonth.format(DateTimeFormatter.ofPattern("yyyyMM"));
            System.out.println(str);
         //String -> YearMonth -> LocalDate
            YearMonth yearMonth = YearMonth.parse("202008", DateTimeFormatter.ofPattern("yyyyMM"));
            LocalDate localDate = LocalDate.of(yearMonth.getYear(), yearMonth.getMonthValue(), 1);
            System.out.println(localDate.toString())

    参考: https://blog.csdn.net/neweastsun/article/details/81702426    YearMonth

  • 相关阅读:
    Git
    Spring
    Linux
    Linux
    Linux
    Linux
    Linux
    Linux
    Linux
    Linux
  • 原文地址:https://www.cnblogs.com/smileblogs/p/13426355.html
Copyright © 2011-2022 走看看