import java.text.DecimalFormat; import java.time.LocalDate; import java.time.temporal.ChronoUnit; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); for (int i = 0; i < n; i++) { int year = scanner.nextInt(); int month = scanner.nextInt(); int day = scanner.nextInt(); int num = scanner.nextInt(); LocalDate date = LocalDate.of(year, month, day); LocalDate date1 = date.plus(num, ChronoUnit.DAYS); DecimalFormat f = new DecimalFormat("00"); System.out.println(date1.getYear()+"-"+f.format(date1.getMonth().getValue())+"-"+f.format(date1.getDayOfMonth())); } } }
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int m = sc.nextInt();
for (int i = 0; i < m; i++) {
int year = sc.nextInt();
int month = sc.nextInt();
int day = sc.nextInt();
int s = sc.nextInt();
boolean flag=true;
while (flag) {
switch (month) {
case 2:
if (leapYear(year)) {
if (s > 29 - day) {
s = s - (29 - day);
month++;
if (month > 12) {
month = month - 12;
year++;
}
day = 0;
} else {
day = day + s;
flag=false;
}
} else {
if (s > 28 - day) {
s = s - (28 - day);
month++;
if (month > 12) {
month = month - 12;
year++;
}
day = 0;
} else {
day = day + s;
}
}
break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
if (s > 31 - day) {
s = s - (31 - day);
month++;
if (month > 12) {
month = month - 12;
year++;
}
day = 0;
} else {
day = day + s;
flag=false;
}
break;
case 4:
case 6:
case 9:
case 11:
if (s > 30 - day) {
s = s - (30 - day);
month++;
if (month > 12) {
month = month - 12;
year++;
}
day = 0;
} else {
day = day + s;
flag=false;
}
break;
}
}
if(month<10){
if(day<10){
System.out.println(year+"-0"+month+"-0"+day);
}else{
System.out.println(year+"-0"+month+"-"+day);
}
}else{
if(day<10){
System.out.println(year+"-"+month+"-0"+day);
}else{
System.out.println(year+"-"+month+"-"+day);
}
}
}
}
public static boolean leapYear(int year) {
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
return true;
} else {
return false;
}
}
}
import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); int total; int year, mouth, day, plus; int caseNum = 0; Calendar calendar = Calendar.getInstance(); total = scanner.nextInt(); while (caseNum++ < total) { year = scanner.nextInt(); mouth = scanner.nextInt(); day = scanner.nextInt(); plus = scanner.nextInt(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, mouth - 1); calendar.set(Calendar.DATE, day); calendar.add(Calendar.DAY_OF_MONTH, plus); System.out.println(format.format(calendar.getTime())); } } }