Java获取今天 开始和结束时间

 1     /**
 2      * 获取今天开始时间
 3      */
 4     private Long getStartTime() {
 5         Calendar todayStart = Calendar.getInstance();
 6         todayStart.set(Calendar.HOUR, 0);
 7         todayStart.set(Calendar.MINUTE, 0);
 8         todayStart.set(Calendar.SECOND, 0);
 9         todayStart.set(Calendar.MILLISECOND, 0);
10         return todayStart.getTime().getTime();
11     }
12 
13     /**
14      * 获取今天结束时间
15      */
16     private Long getEndTime() {
17         Calendar todayEnd = Calendar.getInstance();
18         todayEnd.set(Calendar.HOUR, 23);
19         todayEnd.set(Calendar.MINUTE, 59);
20         todayEnd.set(Calendar.SECOND, 59);
21         todayEnd.set(Calendar.MILLISECOND, 999);
22         return todayEnd.getTime().getTime();
23     }

 

转载于:https://www.cnblogs.com/jijunjie/p/11207845.html

你可能感兴趣的:(Java获取今天 开始和结束时间)