编辑代码

import java.util.ArrayList;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.SimpleTimeZone;
import java.util.TimeZone;

class Main {
public static void main(String[] args) {
        Calendar todayStart = Calendar.getInstance();
        Calendar todayEnd = Calendar.getInstance();

        String timeZone= "GMT+0200";
        if(timeZone != null){
            TimeZone tz = TimeZone.getTimeZone(timeZone);
            todayStart.setTimeZone(tz);
            todayEnd.setTimeZone(tz);
        }
        //Date date = new Date(1628956799999L);
        //Date date = new Date(1628956800000L);
        Date date = new Date(1628932714632L);
        System.out.println(date);
        System.out.println(date.getTime());
        todayStart.clear();
        System.out.println("------------------------");
        todayStart.setTime(date);
        todayStart.set(Calendar.HOUR_OF_DAY, 0);
        todayStart.set(Calendar.MINUTE, 0);
        todayStart.set(Calendar.SECOND, 0);
        todayStart.set(Calendar.MILLISECOND, 0);
        System.out.println(todayStart.getTime().getTime());

        todayEnd.clear();
        todayEnd.setTime(date);
        todayEnd.set(Calendar.HOUR_OF_DAY, 23);
        todayEnd.set(Calendar.MINUTE, 59);
        todayEnd.set(Calendar.SECOND, 59);
        todayEnd.set(Calendar.MILLISECOND, 999);
        System.out.println(todayEnd.getTime().getTime());

 /*       Calendar currentMinuteStart = Calendar.getInstance();
//        currentMinuteStart.set(Calendar.HOUR_OF_DAY, 0);
//        currentMinuteStart.set(Calendar.MINUTE, 0);
        currentMinuteStart.set(Calendar.SECOND, 0);
        currentMinuteStart.set(Calendar.MILLISECOND, 0);
        System.out.println(currentMinuteStart.getTime().getTime());


        Calendar currentMinuteEnd = Calendar.getInstance();
//        currentMinuteEnd.set(Calendar.HOUR_OF_DAY, 23);
//        currentMinuteEnd.set(Calendar.MINUTE, 59);
        currentMinuteEnd.set(Calendar.SECOND, 59);
        currentMinuteEnd.set(Calendar.MILLISECOND, 999);
        System.out.println(currentMinuteEnd.getTime().getTime());

        System.out.println(Long.parseLong(currentMinuteStart.getTime().getTime()/1000 + ""));
        System.out.println(Long.parseLong(currentMinuteEnd.getTime().getTime()/1000 + ""));
        */
    }

}