2016-12-06 175 views

回答

0

我嘗試這樣做如下:

DateTimeFormatter customFormatter = new DateTimeFormatterBuilder() 
     .appendLiteral("New Year in ") 
     .appendValue(ChronoField.YEAR) 
     .appendLiteral(" was on ") 
     .appendText(ChronoField.DAY_OF_WEEK,TextStyle.FULL_STANDALONE) 
     .toFormatter(); 

    LocalDate ld1 = LocalDate.of(2016, Month.JANUARY, 1); 
    String formatted = ld1.format(customFormatter); 
    System.out.println(formatted); 

但是,我認爲它有一個流程,我們需要明確地傳遞準確的新的一年的日期。但是,它解決了我特別解析/格式化日期的問題。

相關問題