广州市综治平台后端
xusd
2025-06-07 36306491396230522fa20585c2621a7fc899849a
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
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
package cn.huge.base.common.utils;
 
import org.apache.commons.lang3.StringUtils;
 
import java.text.SimpleDateFormat;
import java.util.*;
 
/**
 * @title: 时间工具类
 * @description: 时间工具类
 * @company: hugeinfo
 * @author: liyj
 * @time: 2021-11-05 16:51:48
 * @version: 1.0.0
 */
public class DateUtils {
 
    public static void main(String[] args) {
 
    }
 
    /**
     * 各时间格式
     */
    public static String YYYY_MM_DD_HH_MM_SS ="yyyy-MM-dd HH:mm:ss";
    public static String YYYY_MM_DD_HH_MM ="yyyy-MM-dd HH:mm";
    public static String YYYY_MM_DD ="yyyy-MM-dd";
    public static String HH_MM_SS ="HH:mm:ss";
    public static String YYYYMMDD ="yyyyMMdd";
    private static String DATE_FORMAT_1 = "yyyy.MM.dd";
    private static String DATE_FORMAT_2 = "yyyy/MM/dd";
    private static String DATE_FORMAT_3 = "yyyy-MM";
    private static String DATE_FORMAT_4 = "yyyy.MM";
    private static String DATE_FORMAT_5 = "yyyy/MM";
 
    /**
     * 时间格式枚举
     */
    enum DateStyle {
        MM_DD("MM-dd"),
        YYYY_MM("yyyy-MM"),
        YYYY_MM_DD("yyyy-MM-dd"),
        MM_DD_HH_MM("MM-dd HH:mm"),
        MM_DD_HH_MM_SS("MM-dd HH:mm:ss"),
        YYYY_MM_DD_HH_MM("yyyy-MM-dd HH:mm"),
        YYYY_MM_DD_HH_MM_SS("yyyy-MM-dd HH:mm:ss"),
 
        MM_DD_EN("MM/dd"),
        YYYY_MM_EN("yyyy/MM"),
        YYYY_MM_DD_EN("yyyy/MM/dd"),
        MM_DD_HH_MM_EN("MM/dd HH:mm"),
        MM_DD_HH_MM_SS_EN("MM/dd HH:mm:ss"),
        YYYY_MM_DD_HH_MM_EN("yyyy/MM/dd HH:mm"),
        YYYY_MM_DD_HH_MM_SS_EN("yyyy/MM/dd HH:mm:ss"),
 
        MM_DD_CN("MMdd"),
        YYYY_MM_CN("yyyyMM"),
        YYYY_MM_DD_CN("yyyyMMdd"),
        MM_DD_HH_MM_CN("MMdd HH:mm"),
        MM_DD_HH_MM_SS_CN("MMdd HH:mm:ss"),
        YYYY_MM_DD_HH_MM_CN("yyyyMMdd HH:mm"),
        YYYY_MM_DD_HH_MM_SS_CN("yyyyMMdd HH:mm:ss"),
 
        HH_MM("HH:mm"),
        HH_MM_SS("HH:mm:ss");
 
        private String value;
 
        DateStyle(String value) {
            this.value = value;
        }
 
        public String getValue() {
            return value;
        }
    }
 
    /**
     * 周枚举
     */
    enum Week {
        MONDAY("һ", "Monday", "Mon.", 1),
        TUESDAY("ڶ", "Tuesday", "Tues.", 2),
        WEDNESDAY("", "Wednesday", "Wed.", 3),
        THURSDAY("", "Thursday", "Thur.", 4),
        FRIDAY("", "Friday", "Fri.", 5),
        SATURDAY("", "Saturday", "Sat.", 6),
        SUNDAY("", "Sunday", "Sun.", 7);
 
        String name_cn;
        String name_en;
        String name_enShort;
        int number;
 
        Week(String name_cn, String name_en, String name_enShort, int number) {
            this.name_cn = name_cn;
            this.name_en = name_en;
            this.name_enShort = name_enShort;
            this.number = number;
        }
 
        public String getChineseName() {
            return name_cn;
        }
 
        public String getName() {
            return name_en;
        }
 
        public String getShortName() {
            return name_enShort;
        }
 
        public int getNumber() {
            return number;
        }
    }
 
    /**
     * 解析各种格式出生年月,获取日期
     * @param birthdate
     * @return
     */
    public static Date getDateByString(String birthdate) {
        Date date = null;
        try{
            birthdate = birthdate.trim();
            if(birthdate.length() > 8){
                if(birthdate.contains("-")){
                    date = getDateFormat(YYYY_MM_DD).parse(birthdate);
                }else if(birthdate.contains(".")){
                    date = getDateFormat(DATE_FORMAT_1).parse(birthdate);
                }else if(birthdate.contains("/")){
                    date = getDateFormat(DATE_FORMAT_2).parse(birthdate);
                }
            }else{
                if(birthdate.contains("-")){
                    date = getDateFormat(DATE_FORMAT_3).parse(birthdate);
                }else if(birthdate.contains(".")){
                    date = getDateFormat(DATE_FORMAT_4).parse(birthdate);
                }else if(birthdate.contains("/")){
                    date = getDateFormat(DATE_FORMAT_5).parse(birthdate);
                }
            }
        }catch (Exception e){
 
        }
        return date;
    }
 
    /**
     * 获取两个日期相差天数
     * @param date 时间戳
     * @param otherDate 第二个时间戳
     * @return int
     */
    public static int getIntervalDays(String date, String otherDate) {
        return getIntervalDays(StringToDate(date), StringToDate(otherDate));
    }
 
    /**
     * 获取两个日期相差天数
     * @param date 时间
     * @param otherDate 第二个时间
     * @return int
     */
    public static int getIntervalDays(Date date, Date otherDate) {
        date = DateUtils.StringToDate(DateUtils.getDate(date));
        long time = Math.abs(date.getTime() - otherDate.getTime());
        return (int)time/(24 * 60 * 60 * 1000);
    }
 
    /**
     * 获取当前时间
     * @return Date
     */
    public static Date getNowDate(){
        return new Date();
    }
 
    /**
     * 获取当前时间的月份
     * @return String
     */
    public static String getThisMonth(){
        SimpleDateFormat format = getDateFormat(YYYY_MM_DD);
        Calendar c = Calendar.getInstance();
        c.add(Calendar.MONTH, 0);
        c.set(Calendar.DAY_OF_MONTH,1);//Ϊ1,ǰڼΪµһ
        String thisMonth = format.format(c.getTime());
        return thisMonth;
    }
 
    /**
     * 获取当前时间的下一月份
     * @return String
     */
    public static String getNextMonth(){
        SimpleDateFormat format = getDateFormat(YYYY_MM_DD);
        Calendar cal_1=Calendar.getInstance();
        cal_1.add(Calendar.MONTH, +1);
        cal_1.set(Calendar.DAY_OF_MONTH,1);
        String nextMonth = format.format(cal_1.getTime());
        return nextMonth;
    }
 
    /**
     * 字符串时间戳转Date
     * @param date
     * @return Date
     */
    public static Date StringToDate(String date) {
        DateStyle dateStyle = null;
        return StringToDate(date, dateStyle);
    }
 
    /**
     * Date转Int
     * @param date 时间
     * @param dateType 时间类型(年、月、日、时、分、秒等)
     * @return int
     */
    private static int getInteger(Date date, int dateType) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.get(dateType);
    }
 
    /**
     * 时间计算,返回字符串
     * @param date 时间戳
     * @param dateType 时间类型(年、月、日、时、分、秒等)
     * @param amount 偏移量
     * @return String
     */
    private static String addInteger(String date, int dateType, int amount) {
        String dateString = null;
        DateStyle dateStyle = getDateStyle(date);
        if (dateStyle != null) {
            Date myDate = StringToDate(date, dateStyle);
            myDate = addInteger(myDate, dateType, amount);
            dateString = DateToString(myDate, dateStyle);
        }
        return dateString;
    }
 
    /**
     * 时间计算,返回Date
     * @param date 时间戳
     * @param dateType 时间类型(年、月、日、时、分、秒等)
     * @param amount 偏移量
     * @return Date
     */
    private static Date addInteger(Date date, int dateType, int amount) {
        Date myDate = null;
        if (date != null) {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            calendar.add(dateType, amount);
            myDate = calendar.getTime();
        }
        return myDate;
    }
 
    /**
     * 时间年份偏移计算
     * @param date 时间戳
     * @param yearAmount 偏移量
     * @return String
     */
    public static String addYear(String date, int yearAmount) {
        return addInteger(date, Calendar.YEAR, yearAmount);
    }
 
    /**
     * 时间年份偏移计算
     * @param date 时间
     * @param yearAmount 偏移量
     * @return Date
     */
    public static Date addYear(Date date, int yearAmount) {
        return addInteger(date, Calendar.YEAR, yearAmount);
    }
 
    /**
     * 时间月份偏移计算
     * @param date 时间戳
     * @param monthAmount 偏移量
     * @return String
     */
    public static String addMonth(String date, int monthAmount) {
        return addInteger(date, Calendar.MONTH, monthAmount);
    }
 
    /**
     * 时间月份偏移计算
     * @param date 时间
     * @param monthAmount 偏移量
     * @return Date
     */
    public static Date addMonth(Date date, int monthAmount) {
        return addInteger(date, Calendar.MONTH, monthAmount);
    }
 
    /**
     * 时间天数偏移计算
     * @param date 时间戳
     * @param dayAmount 偏移量
     * @return String
     */
    public static String addDay(String date, int dayAmount) {
        return addInteger(date, Calendar.DATE, dayAmount);
    }
 
    /**
     * 时间天数偏移计算
     * @param date 时间
     * @param dayAmount 偏移量
     * @return Date
     */
    public static Date addDay(Date date, int dayAmount) {
        return addInteger(date, Calendar.DATE, dayAmount);
    }
 
    /**
     * 时间小时偏移计算
     * @param date 时间戳
     * @param hourAmount 偏移量
     * @return String
     */
    public static String addHour(String date, int hourAmount) {
        return addInteger(date, Calendar.HOUR_OF_DAY, hourAmount);
    }
 
    /**
     * 时间小时偏移计算
     * @param date 时间
     * @param hourAmount 偏移量
     * @return Date
     */
    public static Date addHour(Date date, int hourAmount) {
        return addInteger(date, Calendar.HOUR_OF_DAY, hourAmount);
    }
 
    /**
     * 时间分钟偏移计算
     * @param date 时间戳
     * @param minuteAmount 偏移量
     * @return String
     */
    public static String addMinute(String date, int minuteAmount) {
        return addInteger(date, Calendar.MINUTE, minuteAmount);
    }
 
    /**
     * 时间分钟偏移计算
     * @param date 时间
     * @param minuteAmount 偏移量
     * @return Date
     */
    public static Date addMinute(Date date, int minuteAmount) {
        return addInteger(date, Calendar.MINUTE, minuteAmount);
    }
 
    /**
     * 时间秒偏移计算
     * @param date 时间戳
     * @param secondAmount 偏移量
     * @return String
     */
    public static String addSecond(String date, int secondAmount) {
        return addInteger(date, Calendar.SECOND, secondAmount);
    }
 
    /**
     * 时间秒偏移计算
     * @param date 时间
     * @param secondAmount 偏移量
     * @return Date
     */
    public static Date addSecond(Date date, int secondAmount) {
        return addInteger(date, Calendar.SECOND, secondAmount);
    }
 
    /**
     * 获取时间的年份
     * @param date 时间戳
     * @return
     */
    public static int getYear(String date) {
        return getYear(StringToDate(date));
    }
 
    /**
     * 获取时间的年份
     * @param date 时间
     * @return
     */
    public static int getYear(Date date) {
        return getInteger(date, Calendar.YEAR);
    }
 
    /**
     * 获取时间的月份
     * @param date 时间戳
     * @return
     */
    public static int getMonth(String date) {
        return getMonth(StringToDate(date));
    }
 
    /**
     * 获取时间的月份
     * @param date 时间
     * @return
     */
    public static int getMonth(Date date) {
        return getInteger(date, Calendar.MONTH);
    }
 
    /**
     * 获取时间的天
     * @param date 时间戳
     * @return
     */
    public static int getDay(String date) {
        return getDay(StringToDate(date));
    }
 
    /**
     * 获取时间的天
     * @param date 时间
     * @return
     */
    public static int getDay(Date date) {
        return getInteger(date, Calendar.DATE);
    }
 
    /**
     * 获取时间的小时
     * @param date 时间戳
     * @return
     */
    public static int getHour(String date) {
        return getHour(StringToDate(date));
    }
 
    /**
     * 获取时间的小时
     * @param date 时间
     * @return
     */
    public static int getHour(Date date) {
        return getInteger(date, Calendar.HOUR_OF_DAY);
    }
 
    /**
     * 获取时间的分钟
     * @param date 时间戳
     * @return
     */
    public static int getMinute(String date) {
        return getMinute(StringToDate(date));
    }
 
    /**
     * 获取时间的分钟
     * @param date 时间
     * @return
     */
    public static int getMinute(Date date) {
        return getInteger(date, Calendar.MINUTE);
    }
 
    /**
     * 获取时间的秒
     * @param date 时间戳
     * @return
     */
    public static int getSecond(String date) {
        return getSecond(StringToDate(date));
    }
 
    /**
     * 获取时间的秒
     * @param date 时间
     * @return
     */
    public static int getSecond(Date date) {
        return getInteger(date, Calendar.SECOND);
    }
 
    /**
     * 获取日期
     * @param date 时间戳
     * @return
     */
    public static String getDate(String date) {
        return StringToString(date, DateStyle.YYYY_MM_DD);
    }
 
    /**
     * 获取日期
     * @param date 时间
     * @return
     */
    public static String getDate(Date date) {
        return DateToString(date, DateStyle.YYYY_MM_DD);
    }
 
    /**
     * 获取时分秒
     * @param date 时间戳
     * @return
     */
    public static String getTime(String date) {
        return StringToString(date, DateStyle.HH_MM_SS);
    }
 
    /**
     * 获取时分秒
     * @param date 时间
     * @return
     */
    public static String getTime(Date date) {
        return DateToString(date, DateStyle.HH_MM_SS);
    }
 
    /**
     * 获取周
     * @param date 时间戳
     * @return
     */
    public static Week getWeek(String date) {
        Week week = null;
        DateStyle dateStyle = getDateStyle(date);
        if (dateStyle != null) {
            Date myDate = StringToDate(date, dateStyle);
            week = getWeek(myDate);
        }
        return week;
    }
 
    /**
     * 获取周
     * @param date 时间
     * @return
     */
    public static Week getWeek(Date date) {
        Week week = null;
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        int weekNumber = calendar.get(Calendar.DAY_OF_WEEK) - 1;
        switch (weekNumber) {
            case 0:
                week = Week.SUNDAY;
                break;
            case 1:
                week = Week.MONDAY;
                break;
            case 2:
                week = Week.TUESDAY;
                break;
            case 3:
                week = Week.WEDNESDAY;
                break;
            case 4:
                week = Week.THURSDAY;
                break;
            case 5:
                week = Week.FRIDAY;
                break;
            case 6:
                week = Week.SATURDAY;
                break;
        }
        return week;
    }
 
    /**
     * 判断字符串是否是时间戳
     * @param date 时间戳
     * @return boolean
     */
    public static boolean isDate(String date) {
        boolean isDate = false;
        if (date != null) {
            if (StringToDate(date) != null) {
                isDate = true;
            }
        }
        return isDate;
    }
 
    /**
     * 获取字符串时间戳格式
     * @param date 时间戳
     * @return DateStyle
     */
    public static DateStyle getDateStyle(String date) {
        DateStyle dateStyle = null;
        Map<Long, DateStyle> map = new HashMap<Long, DateStyle>();
        List<Long> timestamps = new ArrayList<Long>();
        for (DateStyle style : DateStyle.values()) {
            Date dateTmp = StringToDate(date, style.getValue());
            if (dateTmp != null) {
                timestamps.add(dateTmp.getTime());
                map.put(dateTmp.getTime(), style);
            }
        }
        dateStyle = map.get(getAccurateDate(timestamps).getTime());
        return dateStyle;
    }
 
    /**
     * 获取SimpleDateFormat对象
     * @param format 格式
     * @return SimpleDateFormat
     * @throws RuntimeException
     */
    private static SimpleDateFormat getDateFormat(String format) throws RuntimeException {
        return new SimpleDateFormat(format);
    }
 
    public static String dateToString2(Date date) {
        return new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS).format(date);
    }
 
    /**
     * 字符串转Date
     * @param date 时间戳
     * @param format 格式
     * @return Date
     */
    public static Date StringToDate(String date, String format) {
        Date myDate = null;
        if (date != null) {
            try {
                myDate = getDateFormat(format).parse(date);
            } catch (Exception e) {
            }
        }
        return myDate;
    }
 
    /**
     * 字符串时间戳转Date
     * @param date  时间戳
     * @param dateStyle  时间示例
     * @return Date
     */
    public static Date StringToDate(String date, DateStyle dateStyle) {
        Date myDate = null;
        if (dateStyle == null) {
            List<Long> timestamps = new ArrayList<Long>();
            for (DateStyle style : DateStyle.values()) {
                Date dateTmp = StringToDate(date, style.getValue());
                if (dateTmp != null) {
                    timestamps.add(dateTmp.getTime());
                }
            }
            myDate = getAccurateDate(timestamps);
        } else {
            myDate = StringToDate(date, dateStyle.getValue());
        }
        return myDate;
    }
 
    /**
     * Date转字符串
     * @param date 时间
     * @param format 格式
     * @return String
     */
    public static String DateToString(Date date, String format) {
        String dateString = null;
        if (date != null) {
            try {
                dateString = getDateFormat(format).format(date);
            } catch (Exception e) {
            }
        }
        return dateString;
    }
 
    /**
     * Date转字符串
     * @param date 时间
     * @param dateStyle 时间示例
     * @return String
     */
    public static String DateToString(Date date, DateStyle dateStyle) {
        String dateString = null;
        if (dateStyle != null) {
            dateString = DateToString(date, dateStyle.getValue());
        }
        return dateString;
    }
 
    /**
     * 字符串时间戳转字符串
     * @param date 时间
     * @param format 格式
     * @return String
     */
    public static String StringToString(String date, String format) {
        return StringToString(date, null, format);
    }
 
    /**
     * 字符串时间戳转字符串
     * @param date 时间
     * @param dateStyle 时间示例
     * @return String
     */
    public static String StringToString(String date, DateStyle dateStyle) {
        return StringToString(date, null, dateStyle);
    }
 
    /**
     * 字符串时间戳转字符串
     * @param date 时间
     * @param olddFormat 旧格式
     * @param newFormat 新格式
     * @return String
     */
    public static String StringToString(String date, String olddFormat, String newFormat) {
        String dateString = null;
        if (olddFormat == null) {
            DateStyle style = getDateStyle(date);
            if (style != null) {
                Date myDate = StringToDate(date, style.getValue());
                dateString = DateToString(myDate, newFormat);
            }
        } else {
            Date myDate = StringToDate(date, olddFormat);
            dateString = DateToString(myDate, newFormat);
        }
        return dateString;
    }
 
    /**
     * 字符串时间戳转字符串
     * @param date 时间
     * @param olddDteStyle 旧时间示例
     * @param newDateStyle 新时间示例
     * @return String
     */
    public static String StringToString(String date, DateStyle olddDteStyle, DateStyle newDateStyle) {
        String dateString = null;
        if (olddDteStyle == null) {
            DateStyle style = getDateStyle(date);
            dateString = StringToString(date, style.getValue(), newDateStyle.getValue());
        } else {
            dateString = StringToString(date, olddDteStyle.getValue(), newDateStyle.getValue());
        }
        return dateString;
    }
 
    /**
     * 获取两个日期之间所有日期
     * @param beginDatestr
     * @param endDatestr
     * @return
     * @throws Exception
     */
    public static List<String> genDateRange(String beginDatestr,String endDatestr) throws Exception{
        Date beginDate = DateUtils.StringToDate(beginDatestr, DateUtils.YYYY_MM_DD);
        Date endDate = DateUtils.StringToDate(endDatestr, DateUtils.YYYY_MM_DD);
        if(beginDate.after(endDate)){
            throw new Exception("");
        }
        List<String> datestrList = new ArrayList();
        while(true){
            String tmpbeginstr = DateUtils.DateToString(beginDate, DateUtils.YYYY_MM_DD);
            if(tmpbeginstr.equals(endDatestr)){
                break;
            }
            beginDate = DateUtils.addDay(beginDate, 1);
            datestrList.add(tmpbeginstr);
        }
        return datestrList;
    }
 
    /**
     * 获取两个日期之间所有月份
     * @param beginMonthstr
     * @param endMonthstr
     * @return
     * @throws Exception
     */
    public static List<String> genMonthRange(String beginMonthstr,String endMonthstr) throws Exception{
        Date beginDate = DateUtils.StringToDate(beginMonthstr, "yyyy-MM");
        Date endDate = DateUtils.StringToDate(endMonthstr,  "yyyy-MM");
        if(beginDate.after(endDate)){
            throw new Exception("");
        }
        List<String> datestrList = new ArrayList();
        while(true){
            String tmpbeginstr = DateUtils.DateToString(beginDate, "yyyy-MM");
            if(tmpbeginstr.equals(endMonthstr)){
                break;
            }
            beginDate = DateUtils.addMonth(beginDate, 1);
            datestrList.add(tmpbeginstr);
        }
        return datestrList;
    }
 
    /**
     * 获取一个日期往前/后推几个月的所有月份(包括自己)
     * @param beginMonth 日期
     * @param addMonth 推几个月
     * @return
     * @throws Exception
     */
    public static List<String> genMonthRange(Date beginMonth, int addMonth) throws Exception{
        // 转换为yyyy-MM格式
        String beginMonthStr = DateUtils.DateToString(beginMonth, "yyyy-MM");
        Date beginDate = DateUtils.StringToDate(beginMonthStr, "yyyy-MM");
        // 计算月份集合
        List<String> dateStrList = new ArrayList();
        dateStrList.add(beginMonthStr);
        if (addMonth != 0) {
            // 如果addMonth不为0,计算出endDate
            if (addMonth > 0) {
                for (int i = 1; i <= addMonth; i++) {
                    Date nextDate = DateUtils.addMonth(beginDate, i);
                    String nextMonthStr = DateUtils.DateToString(nextDate, "yyyy-MM");
                    dateStrList.add(nextMonthStr);
                }
            }
            if (addMonth < 0) {
                for (int i = -1; i >= addMonth; i--) {
                    Date nextDate = DateUtils.addMonth(beginDate, i);
                    String nextMonthStr = DateUtils.DateToString(nextDate, "yyyy-MM");
                    dateStrList.add(0, nextMonthStr);
                }
            }
        }
        return dateStrList;
    }
 
    /**
     * 获取精准时间Date
     * @param timestamps
     * @return
     */
    private static Date getAccurateDate(List<Long> timestamps) {
        Date date = null;
        long timestamp = 0;
        Map<Long, long[]> map = new HashMap<Long, long[]>();
        List<Long> absoluteValues = new ArrayList<Long>();
        if (timestamps != null && timestamps.size() > 0) {
            if (timestamps.size() > 1) {
                for (int i = 0; i < timestamps.size(); i++) {
                    for (int j = i + 1; j < timestamps.size(); j++) {
                        long absoluteValue = Math.abs(timestamps.get(i) - timestamps.get(j));
                        absoluteValues.add(absoluteValue);
                        long[] timestampTmp = { timestamps.get(i), timestamps.get(j) };
                        map.put(absoluteValue, timestampTmp);
                    }
                }
                long minAbsoluteValue = -1;
                if (!absoluteValues.isEmpty()) {
                    minAbsoluteValue = absoluteValues.get(0);
                }
                for (int i = 0; i < absoluteValues.size(); i++) {
                    for (int j = i + 1; j < absoluteValues.size(); j++) {
                        if (absoluteValues.get(i) > absoluteValues.get(j)) {
                            minAbsoluteValue = absoluteValues.get(j);
                        } else {
                            minAbsoluteValue = absoluteValues.get(i);
                        }
                    }
                }
                if (minAbsoluteValue != -1) {
                    long[] timestampsLastTmp = map.get(minAbsoluteValue);
                    if (absoluteValues.size() > 1) {
                        timestamp = Math.max(timestampsLastTmp[0], timestampsLastTmp[1]);
                    } else if (absoluteValues.size() == 1) {
                        long dateOne = timestampsLastTmp[0];
                        long dateTwo = timestampsLastTmp[1];
                        if ((Math.abs(dateOne - dateTwo)) < 100000000000L) {
                            timestamp = Math.max(timestampsLastTmp[0], timestampsLastTmp[1]);
                        } else {
                            long now = new Date().getTime();
                            if (Math.abs(dateOne - now) <= Math.abs(dateTwo - now)) {
                                timestamp = dateOne;
                            } else {
                                timestamp = dateTwo;
                            }
                        }
                    }
                }
            } else {
                timestamp = timestamps.get(0);
            }
        }
        if (timestamp != 0) {
            date = new Date(timestamp);
        }
        return date;
    }
 
    public static String replaceNumber(String number){
        String date = number.replace("1", "一").replace("2", "二").replace("3", "三").replace("4", "四").
                replace("5", "五").replace("6", "六").replace("7", "七").replace("8", "八").
                replace("9", "九").replace("0", "〇");
        return date;
    }
 
    public static String getBirthday(String oldBirthday){
        if (StringUtils.isNotEmpty(oldBirthday)) {
            String[] oldBirthdays = oldBirthday.split("-");
            String birthday = oldBirthdays[0] + "年" + oldBirthdays[1] + "月" + oldBirthdays[2] + "日出生,";
            return birthday;
        }else {
            return "";
        }
    }
 
    /**
     * 获取固定格式时间,yyyy年MM月dd日上午
     *
     * @param date
     * @return
     */
    public static String getDocumentTime (Date date){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String newTime = sdf.format(new Date());
        String[] newTimes = newTime.split("-");
        String year = replaceNumber(newTimes[0]);
        String monthNumber = replaceNumber(newTimes[1]);
        char monthCharOne = monthNumber.charAt(0);
        char monthCharTwo = monthNumber.charAt(1);
        String month = "";
        if ('〇' != monthCharOne){
            if ('〇' != monthCharTwo) {
                if ('一' != monthCharOne) {
                    month += monthCharOne + "十" + monthCharTwo;
                }else{
                    month += "十" + monthCharTwo;
                }
            }else{
                if ('一' != monthCharOne) {
                    month += monthCharOne + "十";
                }else{
                    month += "十";
                }
            }
        }else{
            month += monthCharTwo;
        }
        String dayNumber = replaceNumber(newTimes[2]);
        char dayCharOne = dayNumber.charAt(0);
        char dayCharTwo = dayNumber.charAt(1);
        String day = "";
        if ('〇' != dayCharOne){
            if ('〇' != dayCharTwo){
                if ('一' != dayCharOne){
                    day += dayCharOne+"十"+dayCharTwo;
                }else {
                    day += "十"+dayCharTwo;
                }
            }else{
                if ('一' != dayCharOne){
                    day += dayCharOne+"十";
                }else {
                    day += "十";
                }
            }
        }else{
            day += dayCharTwo;
        }
        return year+"年"+month+"月"+day+"日";
    }
 
    /**
     * 获取两个时间的小时差
     * */
    public static Integer getDifferHour(Date time1,Date time2){
        if(ObjectUtils.isNotEmpty(time1) && ObjectUtils.isNotEmpty(time2)){
            long housrs = 1000 * 60 * 60;
            long differ = time1.getTime() - time2.getTime();
            long housr = differ / housrs;
            return Integer.valueOf(String.valueOf(housr));
        }
        return 0;
    }
}
/**
 * -------------------_ooOoo_-------------------
 * ------------------o8888888o------------------
 * ------------------88" . "88------------------
 * ------------------(| -_- |)------------------
 * ------------------O\  =  /O------------------
 * ---------------____/`---'\____---------------
 * -------------.'  \\|     |//  `.-------------
 * ------------/  \\|||  :  |||//  \------------
 * -----------/  _||||| -:- |||||-  \-----------
 * -----------|   | \\\  -  /// |   |-----------
 * -----------| \_|  ''\---/''  |   |-----------
 * -----------\  .-\__  `-`  ___/-. /-----------
 * ---------___`. .'  /--.--\  `. . __----------
 * ------."" '<  `.___\_<|>_/___.'  >'"".-------
 * -----| | :  `- \`.;`\ _ /`;.`/ - ` : | |-----
 * -----\  \ `-.   \_ __\ /__ _/   .-` /  /-----
 * ======`-.____`-.___\_____/___.-`____.-'======
 * -------------------`=---='
 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 * ---------佛祖保佑---hugeinfo---永无BUG----------
 */