fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. System.out.println("Day of week is " + getDay("29","9","2017"));
  13. }
  14.  
  15. public static String getDay(String day, String month, String year) {
  16. String[] dates=new String[]{"SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY"};
  17. Calendar cal=Calendar.getInstance();
  18. cal.set(Integer.valueOf(year),Integer.valueOf(month),Integer.valueOf(day));
  19. System.out.println("Requested date is " + cal.getTime());
  20. int date_of_week=cal.get(Calendar.DAY_OF_WEEK);
  21. return dates[date_of_week-1];
  22. }
  23. }
Success #stdin #stdout 0.1s 2841600KB
stdin
Standard input is empty
stdout
Requested date is Sun Oct 29 08:29:46 GMT 2017
Day of week is SUNDAY