5、编写程序,对输入的年、月、日,给出该天是该年的第多少天?
package java基础编程练习题;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
//5、编写程序,对输入的年、月、日,给出该天是该年的第多少天?
public class test05 {
public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(System.in);
System.out.println("请输入年月日,输入格式为:xx年xx月xx日");
String str=sc.nextLine();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日");
Date time=sdf.parse(str);
SimpleDateFormat sdf1=new SimpleDateFormat("yyyy年MM月dd日,是yyyy年的第D天");
System.out.println(sdf1.format(time));
}
}