标签:package 计算 get scanner new EDA system orm style
1 package com.yhqtv.exer; 2 3 import java.text.ParseException; 4 import java.text.SimpleDateFormat; 5 import java.util.Date; 6 import java.util.Scanner; 7 8 /* 9 * 练习:“三天打鱼两天晒网” 1990-01-01 开始 10 * @author XMKJ yhqtv.com Email:yhqtv@qq.com 11 * @create 2020-05-01-12:57 12 *1990-01-01 00:00 13 */ 14 public class San { 15 public static void main(String[] args) throws ParseException { 16 while (true) { 17 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 18 //接收输入的时间并且转换成Date格式 19 System.out.println("请输入年月日(例如1990-01-01)"); 20 Scanner sc = new Scanner(System.in); 21 String st = sc.next(); 22 Date inputDate = sdf.parse(st); 23 //计算开始的的时间 24 String s = "1990-01-01"; 25 Date parse1 = sdf.parse(s); 26 27 28 long l = inputDate.getTime() - parse1.getTime(); 29 30 long l1 = l / (24 * 60 * 60 * 1000)+1; 31 32 if (l1 % 5 == 1 || l1 % 5 == 2 || l1 % 5 == 3) { 33 System.out.println("在打鱼"); 34 } else { 35 System.out.println("在晒网"); 36 } 37 } 38 } 39 }
标签:package 计算 get scanner new EDA system orm style
原文地址:https://www.cnblogs.com/yhqtv-com/p/12813284.html