2016-10-01 29 views
0
public String getDate() throws ParseException{ 

     DateTimeFormatter formatter = DateTimeFormatter.ofPattern("LL dd, yyyy"); 
     LocalDate date = getPublishDate().toInstant().atZone(ZoneId.of("Europe/Kiev")).toLocalDate(); 
     System.out.println(date); 

     String text = date.format(formatter); 
     System.out.println(text); 

     return text; 
    } 

輸出:轉換月份數到文本呈現

2016-10-01 
10 01, 2016 

我想在文本顯示打印月:10月01日,2016年

getPublishDate - 吸氣私人領域Date publishDate的。

回答

1

可以使用的SimpleDateFormat:

SimpleDateFormat sdf = new SimpleDateFormat("MMMMM dd','yyyy"); 
System.out.println(sdf.format(new Date())); 
//output: "October 01,2016" 
+0

的感謝!你的解決方案幫助了我 – DenysM