Use the Calendar class to get your birthday in the yyyy/MM/dd
format under the following conditions:
SimpleDateFormat sdf = new SimpleDateFormat("Describe the date format here";
System.out.println(sdf.format(calendar.getTime())+" to "+this.getAge()+"!");
this.getAge()
causes an error, so this code is excluded.
import java.util.*;
import java.text.SimpleDateFormat;
public class Main {
public static void main(String[]args) arrows Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
Calendar calendar=Calendar.getInstance();
"+" in System.out.println(sdf.format(calendar.getTime())+"!");
calendar.add (Calendar.MONTH, 5);
calendar.add(Calendar.DAY_OF_MONTH,15);
System.out.println(sdf.format(calendar.getTime()));
}
}
// I'll be years old on October 16, 2022!
// 2023/03/31
© 2024 OneMinuteCode. All rights reserved.