We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Calendar class has a provision to display any field in any style required
I used (in java7):
public static String findDay(int month, int day, int year) {
Calendar day_date = Calendar.getInstance();
day_date.set(year, month - 1, day);
return day_date.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.US).toUpperCase();
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Date and Time
You are viewing a single comment's thread. Return to all comments →
Calendar class has a provision to display any field in any style required
I used (in java7): public static String findDay(int month, int day, int year) { Calendar day_date = Calendar.getInstance(); day_date.set(year, month - 1, day); return day_date.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.US).toUpperCase(); }