Java SimpleDateFormat时间格式化前后,时间戳是否有区别?

public static Boolean validateDateInRange(Date validateDate, Date startDate, Date finishDate) throws ParseException {
        System.out.println("格式化前时间戳: " + validateDate.getTime());
        System.out.println("格式化前时间戳: " + startDate.getTime());
        System.out.println("格式化前时间戳: " + finishDate.getTime());

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

        Date dateValidate = sdf.parse(validateDate.toLocaleString());
        Date dateStart = sdf.parse(startDate.toLocaleString());
        Date dateFinish = sdf.parse(finishDate.toLocaleString());

        System.out.println("格式化后时间戳: " + dateValidate.getTime());
        System.out.println("格式化后时间戳: " + dateStart.getTime());
        System.out.println("格式化后时间戳: " + dateFinish.getTime());

        return dateStart.getTime() <= dateValidate.getTime() && dateFinish.getTime() >= dateValidate.getTime();
    }
结论,有区别,输出如下:
格式化前时间戳: 1614739969827
格式化前时间戳: 1614739969827
格式化前时间戳: 1614739969827

格式化后时间戳: 1614700800000
格式化后时间戳: 1614700800000
格式化后时间戳: 1614700800000

你可能感兴趣的:(人工智能,比特币,大数据,java,项目管理)