标签:== demo1 之间 day color calendar divide sys a记录
import java.time.LocalDate; import java.time.Period; import java.util.Calendar; import java.math.*; public class demo { demo(){ } public void demo1(int y,int m,int d){ System.out.println("下一天是"+y+"年"+m+"月"+(d+1)+"日"); } public void demo2(int y,int m,int d) { Calendar cl = Calendar.getInstance(); cl.set(y,m-1,d); int w = cl.get(Calendar.DAY_OF_WEEK); switch(w) { case 1:System.out.println("星期日");break; case 2:System.out.println("星期一");break; case 3:System.out.println("星期二");break; case 4:System.out.println("星期三");break; case 5:System.out.println("星期四");break; case 6:System.out.println("星期五");break; case 7:System.out.println("星期六");break; } } public void demo3(int y1,int m1,int d1,int y2,int m2,int d2) { LocalDate today = LocalDate.of(y1, m1, d1); System.out.println("Today:" + today); LocalDate oldDate = LocalDate.of(y2, m2, d2); System.out.println("OldDate:" + oldDate); Period p = Period.between(oldDate, today); System.out.printf("目标日期距离今天的时间差:%d 年 %d 个月 %d 天\n", p.getYears(), p.getMonths(), p.getDays()); } public void demo4(BigInteger m1,BigInteger m2) { BigInteger result = new BigInteger("0"); result = m1.add(m2); System.out.println("和为"+result); result = m1.multiply(m2); System.out.println("乘积为"+result); result = m1.subtract(m2); System.out.println("差为"+result); result = m1.divide(m2); System.out.println("商为"+result); } } import java.util.Calendar; import java.util.*; import java.math.*; public class Test3 { public static void main(String [] args) { Calendar cal = Calendar.getInstance(); Scanner sc = new Scanner(System.in); System.out.println("输入1代表输入一个日期,输出这个日期的下一天\r\n" + "2代表输入一个日期,输出这个日期是星期几\r\n" + "3代表输入两个日期,输出这两个日期之间的天数\r\n" + "4代表输入两个整数(多于20位),输出这两个整数的和、差、积、商\r\n" + ""); int n = sc.nextInt(); demo test = new demo();//输入过程省略 if(n==1) { test.demo1(2010,10,1); } if(n==2) { test.demo2(2010, 10, 1); } if(n==3) { test.demo3(2019, 12, 13, 2018, 3, 12); } if(n==4) { BigInteger m1 = new BigInteger("839472983749234234234234234"); BigInteger m2 = new BigInteger("85937450924705925892650347"); test.demo4(m1,m2); } }}
标签:== demo1 之间 day color calendar divide sys a记录
原文地址:https://www.cnblogs.com/zhuimingzhenbai/p/12850822.html