将月份数字转换为文本显示
Convert month number to text presentation
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
我想在文本显示中打印月份:2016 年 10 月 1 日。
getPublishDate
- getter 私有字段 Date publishDate
.
您可以使用 SimpleDateFormat:
SimpleDateFormat sdf = new SimpleDateFormat("MMMMM dd','yyyy");
System.out.println(sdf.format(new Date()));
//output: "October 01,2016"
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
我想在文本显示中打印月份:2016 年 10 月 1 日。
getPublishDate
- getter 私有字段 Date publishDate
.
您可以使用 SimpleDateFormat:
SimpleDateFormat sdf = new SimpleDateFormat("MMMMM dd','yyyy");
System.out.println(sdf.format(new Date()));
//output: "October 01,2016"