JAVA Calendarが生年月日計算を実現

414 ワード

import java.util.Calendar;
import java.util.Scanner;


public class calendardemo {
	
	public static void main(String[] args) {
		
		System.out.println("     :");
		
		Scanner sc=new Scanner(System.in);
		int year=sc.nextInt();
		
		Calendar c=Calendar.getInstance();
		
		c.set(year, 2,1);
		c.add(Calendar.DATE,-1);
		System.out.println("   :"+c.get(Calendar.DATE));
	}

}