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;
import java.time.LocalDate;
class Result {
public static String findDay(int month, int day, int year) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.MONTH,month-1);
cal.set(Calendar.DAY_OF_MONTH,day);
cal.set(Calendar.YEAR,year);
String dayOfWeek = cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.US).toUpperCase();
return dayOfWeek;
}
}
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
String[] firstMultipleInput = br.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);
bw.write(res);
bw.newLine();
br.close();
bw.close();
}
}
Solution 3:
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
try (Scanner scanner = new Scanner(System.in)) {
int month = scanner.nextInt();
int day = scanner.nextInt();
int year = scanner.nextInt();
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DATE, day);
calendar.set(Calendar.MONTH, month - 1);
calendar.set(Calendar.YEAR, year);
System.out.println(calendar.getDisplayName(Calendar.DAY_OF_WEEK,
Calendar.LONG, new Locale("en", "US")).toUpperCase());
}
}
}
Solution 4:
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.Scanner;
public class JavaDateAndTime {
static List<String> days = Arrays.asList("SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY");
public static String getDay(String day, String month, String year) {
int y = Integer.parseInt(year);
int m = Integer.parseInt(month);
int d = Integer.parseInt(day);
Calendar c = Calendar.getInstance();
c.set(y, m-1, d);
int p = c.get(Calendar.DAY_OF_WEEK);
String s = days.get(p-1);
return s;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String month = scanner.next();
String day = scanner.next();
String year = scanner.next();
System.out.println(getDay(day, month, year));
}
}
टिप्पणियाँ
एक टिप्पणी भेजें