//三天打鱼两天晒网,1990-01-01

package c;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

/**
 * @author 真他喵的学不动咯
 * @create 2022-08-05--20:48
 */
public class wor {//三天打鱼两天晒网,1990-01-01
    public static void main(String[] args) throws ParseException {
        int count=0;
        String s1="1990-01-01";
        String s2;
        Scanner scan =new Scanner(System.in);
        System.out.println("请输入你的日期,格式为:xxxx-xx-xx:");
        s2=scan.next();
        //格式化
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        Date d1=sdf.parse(s1);
        Date d2=sdf.parse(s2);
        long p=1+((d2.getTime()-d1.getTime())/(1000*60*60*24));//p是总天数
        if(p%5==1||p%5==2||p%5==3){
            System.out.println("打鱼");
        }
        else if(p%5==4||p%5==0){
            System.out.println("晒网");
        }

       // Date d3=new Date(p);2022-08
       // System.out.println(d3);


    }
}

你可能感兴趣的:(java基础code记录,java,jvm,算法)