【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《从键盘输入年月日,得出这一天是星期几?》,欢迎阅读!
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Scanner;
public class ObtainDate {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("请输入年份");
int a = input.nextInt();
System.out.println("请输入月份");
int b = input.nextInt();
System.out.println("请输入日");
int c = input.nextInt();
Calendar cl = Calendar.getInstance();
cl.set(Calendar.YEAR, a);
cl.set(Calendar.MONTH, b-1 );
cl.set(Calendar.DATE, c);
SimpleDateFormat df = new SimpleDateFormat("yyyy年MM月dd日 EEE");
System.out.println("时间:" + df.format(cl.getTime()));
}
}
相关推荐
最新更新
热门阅读