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;
}
Output:
2016-10-01
10 01, 2016
I want to print month in text presentation: October 01, 2016.
getPublishDate
- getter of private field Date publishDate
.
You can use SimpleDateFormat:
SimpleDateFormat sdf = new SimpleDateFormat("MMMMM dd','yyyy");
System.out.println(sdf.format(new Date()));
//output: "October 01,2016"