static String a(int year) { String res = null; int time_year; int time_month; Date time = new Date(); //2016 2017 2018 2019 2020 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyy-MM-dd"); res = simpleDateFormat.format(time); time_year=Integer.parseInt(res.substring(0,4)); // time_year=2019; // time_month=10; time_month=Integer.parseInt(res.substring(5,7));
public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // int year = sc.nextInt(); for(int i=2010;i<2022;i++){ String t=a(i); System.out.println(i+"的结果:-->"+t); }
//System.out.println(t); }
static String a(int year) { String res = null; int time_year; int time_month; Date time = new Date(); //2016 2017 2018 2019 2020 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyy-MM-dd"); res = simpleDateFormat.format(time); time_year=Integer.parseInt(res.substring(0,4)); // time_year=2019; // time_month=10; time_month=Integer.parseInt(res.substring(5,7));