Java Date and Time

Sort by

recency

|

1498 Discussions

|

  • + 0 comments

    import java.io.; import java.math.; import java.security.; import java.text.; import java.util.; import java.util.concurrent.; import java.util.function.; import java.util.regex.; import java.util.stream.*; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList;

    class Result { public static String findDay(int month,int day,int year) { Calendar c=Calendar.getInstance(); String[] days={"SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY"}; c.set(year,month-1,day); return days[c.get(Calendar.DAY_OF_WEEK)-1]; } }

    public class Sound { public static void main(String[] args) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));

        String[] firstMultipleInput = bufferedReader.readLine().replaceAll("\\s+$", "").split(" ");
    
        int month = Integer.parseInt(firstMultipleInput[0]);
    
        int day = Integer.parseInt(firstMultipleInput[1]);
    
        int year = Integer.parseInt(firstMultipleInput[2]);
    
        String res = Result.findDay(month, day, year);
    
        bufferedWriter.write(res);
        bufferedWriter.newLine();
    
        bufferedReader.close();
        bufferedWriter.close();
    }
    

    }

  • + 0 comments

    i had no idea how to solve this .but thanks to this discussion board.i solved it

  • + 0 comments
    static String findDay(int month, int day, int year) {
        Calendar c = Calendar.getInstance();
            String days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
            c.set(year, month-1, day);
            
            return days[c.get(Calendar.DAY_OF_WEEK)-1].toUpperCase();
        }
    
  • + 0 comments

    Use the Language as java 8

    use function -LocalDate use these imports - import java.time.LocalDate; import java.time.DayOfWeek; import java.util.Locale;

    code ----- LocalDate date = LocalDate.of(year, month, day); DayOfWeek dayOfWeek = date.getDayOfWeek(); return dayOfWeek.name();

  • + 0 comments

    Great for applications that need precise control over calendar data! Fairplay24.in login