Java Date and Time

  • + 3 comments

    You say importing a library is not allowed but yet, you need to import

    java.util.Calendar
    

    and

    java.util.Locale
    

    at least :)

    By the way, here is my solution (Java 7):

    import java.util.*;
    
    public class Solution {
        public static String getDay(String day, String month, String year) {
            Calendar cal = Calendar.getInstance();
            cal.set(Integer.valueOf(year), (Integer.valueOf(month) - 1), Integer.valueOf(day));
            return cal.getDisplayName(Calendar.DAY_OF_WEEK,Calendar.LONG, Locale.getDefault()).toUpperCase();
        }
    }