Teguh Teguh - 4 months ago 19
Java Question

get day name from string date using jodatime

I have string date like this

String s = "29-08-2016";


Desired result is the name of the day of the week:


Monday


How to resolve that?

Answer

Easy takeaway in Joda

String date = "29-08-2016";
LocalDate localDate = DateTimeFormat.forPattern("dd-MM-yyyy").parseLocalDate(date);
System.out.println(DateTimeFormat.forPattern("EEEE").print(localDate));

prints : Monday