I have a string which contains a date "25 December 1985". How to parse it using Joda API?
DateTime dt = new DateTime("25 December 1985");
System.out.println(dt.getDayOfWeek());
I need to get a day of week.
I have a string which contains a date "25 December 1985". How to parse it using Joda API?
DateTime dt = new DateTime("25 December 1985");
System.out.println(dt.getDayOfWeek());
I need to get a day of week.
Try this:
DateTimeFormatter dtf = DateTimeFormat.forPattern("dd MMMM YYYY").withLocale(Locale.ENGLISH);
DateTime dt = dtf.parseDateTime("25 December 1985");
System.out.println(dt.getDayOfWeek());
With reference to http://joda-time.sourceforge.net/userguide.html
getDayOfWeek()
int iDoW = dt.getDayOfWeek();
where iDoW can take the values (from class DateTimeConstants)
public static final int MONDAY = 1;
public static final int TUESDAY = 2;
public static final int WEDNESDAY = 3;
public static final int THURSDAY = 4;
public static final int FRIDAY = 5;
public static final int SATURDAY = 6;
public static final int SUNDAY = 7;
or dayOfWeek()
DateTime.Property pDoW = dt.dayOfWeek();
String strST = pDoW.getAsShortText(); // returns "Mon", "Tue", etc.
String strT = pDoW.getAsText(); // returns "Monday", "Tuesday", etc.