package com.heima.test1;
import java.util.Calendar;
import java.util.Scanner;
public class Test12 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("请输入年月日(格式:xxxx-xx-xx-)");
String str=sc.nextLine();
String[] arr=str.split("-");
int y=Integer.parseInt(arr[0]);
int m=Integer.parseInt(arr[1]);
int d=Integer.parseInt(arr[2]);
Calendar c=Calendar.getInstance();
c.set(y, m-1, d);
System.out.println("这是今年的第"+c.get(Calendar.DAY_OF_YEAR)+"天");
}
} |