420接收网闸文件服务(现场部署版)
Lius
2025-02-27 f06f695488a64dcc0945e282dffe120148f21dca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
package com.mm.util;
 
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Pattern;
 
/**
 * Created by Administrator on 2015/8/28.
 */
public class DateUtil {
    public static final String STR_DATE_STRING = "yyyy_MM_dd";
    public static final String STR_DATE = "yyyy-MM-dd";
    public static final String STRDATE = "yyyyMMdd";
    public static final String STR_YEAR_MONTH = "yyyy-MM";
    public static final String STR_DATE_TIME = "yyyy-MM-dd HH:mm:ss.SSS";
    public static final String STR_DATE_TIME_SMALL = "yyyy-MM-dd HH:mm:ss";
    public static final String STR_DATE_TIME_MIN = "yyyy-MM-dd HH:mm";
    public static final String STR_DATE_TIME_HOUR = "yyyy-MM-dd HH";
    public static final String STR_DATE_TIME_FULL = "yyyyMMddHHmmssSSS";
    public static final String STR_HHMMSS = "HH:mm:ss";
    public static final String STR_HHMM = "HH:mm";
    /**
     * <p>
     * Description: 实际投标月份
     * </p>
     *
     * @param startDate
     * @param endDate
     * @return obj [0] 实际投标月份 例如实际投标月份(3.86)意义是3个月又26天 obj[1] 实际取整月份 (3)
     */
    public static Integer getRealMonth(Date startDate, Date endDate) {
        Integer month = 0;
        Calendar start = Calendar.getInstance();
        start.setTime(startDate);
 
        Calendar end = Calendar.getInstance();
        end.setTime(endDate);
        int year = start.get(Calendar.YEAR);
        int year2 = end.get(Calendar.YEAR);
        int month2 = start.get(Calendar.MONTH);
        int month3 = end.get(Calendar.MONTH);
        try {
            while (start.before(end)) {
                start.add(Calendar.MONTH, 1);
                month++;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        int day2 = start.get(Calendar.DAY_OF_MONTH);
        int day3 = end.get(Calendar.DAY_OF_MONTH);
        int tmpYear = year2 - year;
        if (day2 == day3) {
            return (tmpYear * 12) + (month3 - month2);
        }
        return month == 0 ? month : (month - 1);
    }
 
    public static Date getNow() {
        return new Date(System.currentTimeMillis());
    }
 
    public static int getDayOfMonth() {
        Calendar aCalendar = Calendar.getInstance(Locale.CHINA);
        int day = aCalendar.getActualMaximum(Calendar.DATE);
        return day;
    }
 
    /**
     * <p>
     * Description: 修改时间为指定时间当天的23:59:59.000
     * </p>
     *
     * @param date
     *            需要修改的时间
     * @return 修改后的时间
     */
    public static Date fillTime(Date date) {
        Date result = removeTime(date);
        result.setTime(result.getTime() + 24 * 60 * 60 * 1000 - 1000); // 加一天
        return result;
    }
 
    /**
     * @param date
     *            当前时间
     * @param i
     *            往前几天
     * @return
     */
    public static Date fillBeforeTime(Date date, Integer i) {
        Date result = removeTime(date);
        Calendar calendar = Calendar.getInstance(); // 得到日历
        calendar.setTime(result);// 把当前时间赋给日历
        calendar.add(Calendar.DAY_OF_MONTH, i); // 设置为前一天
        result.setTime(calendar.getTime().getTime() + 24 * 60 * 60 * 1000
                - 1000); // 加一天
        return result;
    }
 
    /**
     * <p>
     * Description: 修改时间为指定时间前一天的00:00:00
     * </p>
     *
     * @param date
     *            需要修改的时间
     * @return 修改后的时间
     */
    public static Date plusTime(Date date, Integer i) {
        Date result = removeTime(date);
        Calendar calendar = Calendar.getInstance(); // 得到日历
        calendar.setTime(result);// 把当前时间赋给日历
        calendar.add(Calendar.DAY_OF_MONTH, i); // 设置为前一天
        return calendar.getTime();
    }
 
    /**
     * <p>
     * Description: 去掉日期时间中的时间部分
     * </p>
     * 如: 2013-11-11 18:56:33 ---> 2013-11-11 00:00:00
     *
     * @param date
     *            需要修改的时间
     * @return 修改后的时间
     */
    public static Date removeTime(Date date) {
        Date result = null;
        try {
            SimpleDateFormat df = new SimpleDateFormat(STR_DATE);
            String dateStr = df.format(date);
            result = df.parse(dateStr);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return result;
    }
 
    /**
     * <p>
     * Description: 按默认格式(yyyy-MM-dd HH:mm:ss.SSS)获取时间字符串
     * </p>
     *
     * @param date
     *            要转换的日期
     * @return 转换后的时间字符串
     */
    public static String format(Date date) {
        SimpleDateFormat df = new SimpleDateFormat(STR_DATE_TIME);
        return df.format(date);
    }
 
    public static Date parseDate(Date date,String format){
        SimpleDateFormat df = new SimpleDateFormat(format);
        try {
            date = df.parse(df.format(date));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
 
    public static Date getDelayedYear(){
        Calendar curr = Calendar.getInstance();
        curr.set(Calendar.YEAR,curr.get(Calendar.YEAR)+1);
        Date date=curr.getTime();
        return date;
    }
    /**
     * <p>
     * Description: 按指定格式获取时间字符串
     * </p>
     *
     * @param date
     *            要转换的日期
     * @param format
     *            格式,例如:yyyy-MM-dd HH:mm:ss.SSS
     * @return 转换后的时间字符串
     */
    public static String format(Date date, String format) {
        SimpleDateFormat df = new SimpleDateFormat(format);
        return df.format(date);
    }
 
    /**
     * <p>
     * Description: 加月函数
     * </p>
     *
     * @param month
     *            月份数
     * @return
     */
    public static Date addMonth(Integer month, Date time) {
        Calendar c = Calendar.getInstance();
        c.setTime(time);
        c.add(Calendar.MONTH, month);
        return c.getTime();
    }
 
    public static Boolean greater(Date startTime, Date endTime) {
        return startTime.getTime() > endTime.getTime();
    }
 
    public static Boolean less(Date startTime, Date endTime) {
        return startTime.getTime() < endTime.getTime();
    }
 
    public static Boolean equals(Date startTime, Date endTime) {
        return startTime.getTime() == endTime.getTime();
    }
 
    public static Integer getDiffMonth(Calendar c, Calendar c1) {
        return (c.get(Calendar.YEAR) - c1.get(Calendar.YEAR)) * 12
                + (c.get(Calendar.MONTH) - c1.get(Calendar.MONTH));
    }
 
    /**
     * 是否为同一天
     */
    public static boolean equalsDay(Date a, Date b) {
        return removeTime(a).getTime() == removeTime(b).getTime();
    }
 
    public static Integer getDays(Date startTime, Date endTime) {
        Calendar c = Calendar.getInstance();
        c.setTime(startTime);
        Calendar c1 = Calendar.getInstance();
        c1.setTime(endTime);
        long t1 = c.getTimeInMillis();
        long t2 = c1.getTimeInMillis();
        // 计算天数
        Long days = (t2 - t1) / (24 * 60 * 60 * 1000);
        return days.intValue();
    }
 
    public static Integer getSeconds(Date startTime, Date endTime) {
        Calendar c = Calendar.getInstance();
        c.setTime(startTime);
        Calendar c1 = Calendar.getInstance();
        c1.setTime(endTime);
        long t1 = c.getTimeInMillis();
        long t2 = c1.getTimeInMillis();
        // 计算秒数
        Long days = (t2 - t1) / (1000);
        return days.intValue();
    }
 
    //获取小时差
    public static double subHours(Date startTime, Date endTime) {
        Calendar c = Calendar.getInstance();
        c.setTime(startTime);
        Calendar c1 = Calendar.getInstance();
        c1.setTime(endTime);
        double t1 = c.getTimeInMillis();
        double t2 = c1.getTimeInMillis();
        // 计算天数
        double hours = (t2 - t1) / (1000 * 60 * 60);
        return Double.valueOf(new DecimalFormat("#.00").format(hours));
    }
    //根据当前时间和出生日期获取年龄
    public static int getAge(Date birthDay){
        Calendar cal = Calendar.getInstance();
        // 取出系统当前时间的年、月、日部分
        int yearNow = cal.get(Calendar.YEAR);
        int monthNow = cal.get(Calendar.MONTH);
        int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH);
        cal.setTime(birthDay);
        // 取出出生日期的年、月、日部分
        int yearBirth = cal.get(Calendar.YEAR);
        int monthBirth = cal.get(Calendar.MONTH);
        int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
        // 当前年份与出生年份相减,初步计算年龄
        int age = yearNow - yearBirth;
        // 当前月份与出生日期的月份相比,如果月份小于出生月份,则年龄上减1,表示不满多少周岁
        if (monthNow <= monthBirth){
            // 如果月份相等,在比较日期,如果当前日,小于出生日,也减1,表示不满多少周岁
            if (monthNow == monthBirth){
                if (dayOfMonthNow < dayOfMonthBirth)
                    age--;
            }else {
                age--;
            }
 
        }
        return age;
    }
 
    public static Date subDays(Date startTime, Integer day) {
        Calendar c = Calendar.getInstance();
        c.setTime(startTime);
        c.add(Calendar.DATE, day * -1);
        return c.getTime();
    }
 
    public static Date addDays(Date startTime, Integer day) {
        Calendar c = Calendar.getInstance();
        c.setTime(startTime);
        c.add(Calendar.DATE, day );
        return c.getTime();
    }
    /*public static Date addHours(Date startTime, Integer hours) {
        Calendar c = Calendar.getInstance();
        c.setTime(startTime);
        c.add(Calendar.HOUR, hours );
        return c.getTime();
    }*/
 
    public static Date toDate(String date, String format){
        SimpleDateFormat df = new SimpleDateFormat(format);
        try {
            return df.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
 
    public static Date toDateFull(String date){
        SimpleDateFormat df = new SimpleDateFormat(STR_DATE_TIME);
        try {
            return df.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
    public static Date toDateMedium(String date){
        SimpleDateFormat df = new SimpleDateFormat(STR_DATE_TIME_SMALL);
        try {
            Date dd = df.parse(date);
            return dd;
        } catch (ParseException e) {
            return null;
        }
    }
    public static Integer getDate(Date date) {
        if (date != null) {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            int day = calendar.get(Calendar.DATE);
            return day;
        }
        return null;
    }
    public static Integer getYear() {
        return getYear(new Date());
    }
    public static Integer getYear(Date date) {
        if (date != null) {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            int year = calendar.get(Calendar.YEAR);
            return year;
        }
        return null;
    }
    public static Integer getMonth() {
        return getMonth(new Date());
    }
    public static Integer getMonth(Date date) {
        if (date != null) {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            int month = calendar.get(Calendar.MONTH);
            return month+1;
        }
        return null;
    }
    public static Integer getDay() {
        return getDay(new Date());
    }
    public static Integer getDay(Date date) {
        if (date != null) {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            int day = calendar.get(Calendar.DAY_OF_MONTH);
            return day;
        }
        return null;
    }
 
 
    public static Date[] getMonthStartTimeAndEndTime(Integer month){
        Calendar calendar = Calendar.getInstance();
        Date[] dates = new Date[2];
        Date startTime = null;
        Date endsTime = null;
        if(month != null){
            calendar.set(Calendar.MONTH, month);
            //获得到本月的第一天
            calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
            startTime = calendar.getTime();
            startTime = DateUtil.removeTime(startTime);
            //获得到本月的最后一天
            calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
            endsTime = calendar.getTime();
            endsTime = DateUtil.fillTime(endsTime);
        }
        dates[0] = startTime;
        dates[1] = endsTime;
        return dates;
    }
    public static Date[] getMonthStartTimeAndEndTime(Date date){
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        Integer month = calendar.get(Calendar.MONTH);
        Date[] dates = new Date[2];
        Date startTime = null;
        Date endsTime = null;
        if(month != null){
            calendar.set(Calendar.MONTH, month);
            //获得到本月的第一天
            calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
            startTime = calendar.getTime();
            startTime = DateUtil.removeTime(startTime);
            //获得到本月的最后一天
            calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
            endsTime = calendar.getTime();
            endsTime = DateUtil.fillTime(endsTime);
        }
        dates[0] = startTime;
        dates[1] = endsTime;
        return dates;
    }
 
    /**
     * 获取days天的时间区间,endTime 为当天的后一天0点,
     * startTime 为endTime前days天
     * @param days
     * @return
     */
    public static Date[] getDaysStartTimeAndEndTime(Integer days) {
        Date[] dates = new Date[2];
        Date endDate = plusTime(removeTime(getNow()), 1);
        Date startDate = subDays(endDate, days);
        dates[0] = startDate;
        dates[1] = endDate;
        return dates;
    }
 
    /**
     * 根据某一年获取最后一天的时间
     * 2013 ---> 2013-12-31 23:59:59.000
     * @param year
     * @return
     */
    public static Date getYearEndDay(Integer year) {
        Calendar calendar = Calendar.getInstance();
        calendar.clear();
        calendar.set(Calendar.YEAR, year);
        calendar.roll(Calendar.DAY_OF_YEAR, -1);
        Date yearLast = calendar.getTime();
        Date lastYear = DateUtil.fillTime(yearLast);
        return lastYear;
    }
 
    /**
     * 获取start/end的所有日期字符串 格式yyyy-MM-dd
     * @param start
     * @param end
     * @return
     */
    public static List<String> getDatesStringList(Date start, Date end) {
        List<String> list = new ArrayList<>();
        int i = getDays(start, end);
        for(int j = 0; j <= i; j++) {
            if(j == 0) {
                list.add(format(start, STR_DATE));
            } else {
                list.add(format(plusTime(start, j), STR_DATE));
            }
        }
        return list;
    }
 
    public static List<String> getMonthBetween(Date start, Date end){
        List<String> list = new ArrayList<>();
        Calendar min = Calendar.getInstance();
        Calendar max = Calendar.getInstance();
        min.setTime(start);
        min.set(min.get(Calendar.YEAR), min.get(Calendar.MONTH), 1);
        max.setTime(end);
        max.set(max.get(Calendar.YEAR), max.get(Calendar.MONTH), 2);
        Calendar curr = min;
        while (curr.before(max)){
            list.add(format(curr.getTime(),STR_YEAR_MONTH));
            curr.add(Calendar.MONTH,1);
        }
        return list;
    }
 
    /**
     * 获取dateStr的日期格式yyyy-MM-dd
     * @param dateStr
     * @return
     */
    public static Date getShortDate(String dateStr) {
        SimpleDateFormat sdf = new SimpleDateFormat(STR_DATE);
        Date startTime = null;
        try {
            startTime = sdf.parse(dateStr);
        } catch (ParseException e) {
        }
        return startTime == null ? removeTime(new Date()) : startTime;
    }
 
    public static Date getFormatDate(String dateStr,String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        Date startTime = null;
        try {
            startTime = sdf.parse(dateStr);
        } catch (ParseException e) {
        }
        return startTime == null ? removeTime(new Date()) : startTime;
    }
 
    /**
     *
     * @param time
     * @param n
     * @return  在一个时间上加秒
     */
    public static Date addSecond(Date time,Integer n) {
        Calendar c = Calendar.getInstance();
        c.setTime(time);
        c.add(Calendar.SECOND, n);
        return c.getTime();
    }
 
    /**
     *
     * @param time
     * @param n
     * @return  在一个时间上加分钟
     */
    public static Date addMinute(Date time,Integer n) {
        Calendar c = Calendar.getInstance();
        c.setTime(time);
        c.add(Calendar.MINUTE, n);
        return c.getTime();
    }
 
    /**
     *
     * @param time
     * @param n
     * @return  在一个时间上加小时
     */
    public static Date addHour(Date time,Integer n) {
        Calendar c = Calendar.getInstance();
        c.setTime(time);
        c.add(Calendar.HOUR_OF_DAY, n);
        return c.getTime();
    }
 
    /**
     * 获取start/end的所有日期字符串 格式yyyy-MM-dd
     * @param start
     * @param end
     * @return
     */
    public static List<String> getDateMonth(String start, String end) {
        List<String> list = new ArrayList<>();
        SimpleDateFormat yyyyMM = new SimpleDateFormat("yyyy-MM");
        Date startyear = null;
        try {
            startyear = yyyyMM.parse(start);
            Date endyear = yyyyMM.parse(end);
            Calendar dd = Calendar.getInstance();//定义日期实例
            dd.setTime(startyear);//设置日期起始时间
            while (dd.getTime().before(endyear)) {//判断是否到结束日期
                String str = yyyyMM.format(dd.getTime());
                dd.add(Calendar.MONTH, 1);//进行当前日期月份加1
                list.add(str);
            }
            list.add(yyyyMM.format(endyear));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return list;
    }
    /**
     * 获取start/end的所有日期字符串 格式yyyy
     * @param start
     * @param end
     * @return
     */
    public static List<String> getDateYear(String start, String end) {
        List<String> list = new ArrayList<>();
        SimpleDateFormat yyyy = new SimpleDateFormat("yyyy");
        Date startyear = null;
        try {
            startyear = yyyy.parse(start);
            Date endyear = yyyy.parse(end);
            Calendar dd = Calendar.getInstance();//定义日期实例
            dd.setTime(startyear);//设置日期起始时间
            while (dd.getTime().before(endyear)) {//判断是否到结束日期
                String str = yyyy.format(dd.getTime());
                dd.add(Calendar.YEAR, 1);//进行当前日期月份加1
                list.add(str);
            }
            list.add(yyyy.format(endyear));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return list;
    }
    /**
     * 获取当前时间 定位到小时
     * 格式为 yyyy-MM-dd hh:mm
     * 例:2018-02-27 11:00
     * @return
     */
    public static Date getNowHourDate() {
        Date now = getNow();
        Date result;
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(now);
        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        String dateStr = format(now, STR_DATE);
        dateStr = dateStr + " " + (hour < 10 ? "0" + hour : hour) + ":00";
        result = toDate(dateStr, STR_DATE_TIME_MIN);
        return result;
    }
 
    /**
     * 获取每日8:11或11:11的时间点
     * @return
     */
    public static Date getNowHourDateTo() {
        Date now = getNow();
        Date result;
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(now);
        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        if(hour != 8 && hour != 11) {
            return null;
        }
        int minute = calendar.get(Calendar.MINUTE);
        if(minute < 11) {
            return null;
        }
        String dateStr = format(now, STR_DATE);
        dateStr = dateStr + " " + (hour < 10 ? "0" + hour : hour) + ":11";
        result = toDate(dateStr, STR_DATE_TIME_MIN);
        return result;
    }
 
    /**
     * 获取每日8:00、13:00、20:00的时间点
     * @return
     */
    public static List<Date> getHourDateList(Date time) {
        List<Date> result = new ArrayList<>();
        result.add(addHour(time,8));
        result.add(addHour(time,13));
        result.add(addHour(time,20));
        return result;
    }
 
    /**
     * 获取上月的最后一天
     * @return
     */
    public static Date getPreviousMonthLastDay() {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_MONTH, 0);
        return DateUtil.removeTime(calendar.getTime());
    }
 
    /**
     * 获取end时间月的第一天
     * @param end 月份最后一天
     * @return
     */
    public static Date getTheMonthFirstDay(Date end) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(end);
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        return calendar.getTime();
    }
 
 
    public static String secToTime(int time) {
        String timeStr = null;
        int hour = 0;
        int minute = 0;
        int second = 0;
        if (time <= 0)
            return " ";
        else {
            minute = time / 60;
            if (minute < 60) {
                second = time % 60;
                timeStr = unitFormat(minute) + "分" + unitFormat(second) + " 秒";
            } else {
                hour = minute / 60;
                minute = minute % 60;
                second = time - hour * 3600 - minute * 60;
                timeStr = unitFormat(hour) + "小时" + unitFormat(minute) + "分" + unitFormat(second) + "秒";
            }
        }
        return timeStr;
    }
 
    public static String unitFormat(int i) {
        String retStr = null;
        if (i >= 0 && i < 10)
            retStr = "0" + Integer.toString(i);
        else
            retStr = "" + i;
        return retStr;
    }
    /**
     * 验证时间
     *
     * @param time 时间字符串 HH:mm
     * @return 验证成功返回true,验证失败返回false
     */
    public static boolean checkTime(String time) {
        String regex = "([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$";
        return Pattern.matches(regex, time);
    }
 
    /**
     * 获取每日07:30:00的时间点
     * 格式为 yyyy-MM-dd HH:mm:ss
     * 例:2018-05-28 07:30:00
     *
     * @return
     */
    public static Date getHourDateTo(Date now, String time) {
        String dateStr = format(now, STR_DATE);
        dateStr = dateStr + " " + time;
        Date result = toDate(dateStr, STR_DATE_TIME_SMALL);
        return result;
    }
}