Teguh Teguh - 3 months ago 10
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