jiangping
2023-10-24 c6d20c6e1db82b204cf59e058bc3ba2a9cd84a1e
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
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
package com.doumee.core.utils;
 
 
 
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
 
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.DateFormatSymbols;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.*;
 
/**
 * 日期工具类
 * @author: jiangping
 * @date:   2021年7月21日09:27:13
 */
public class DateUtil {
 
    static SimpleDateFormat sdfShort = new SimpleDateFormat("yyyyMMdd");
    static SimpleDateFormat sdfLong = new SimpleDateFormat("yyyy-MM-dd");
    static SimpleDateFormat sdfLongSlash = new SimpleDateFormat("yyyy/MM/dd");
    static SimpleDateFormat sdfShortPoint = new SimpleDateFormat("yyyy.MM.dd");
    static SimpleDateFormat sdfLongCn = new SimpleDateFormat("yyyy年MM月dd日");
    static SimpleDateFormat sdfShortU = new SimpleDateFormat("MMM dd", Locale.ENGLISH);
    static SimpleDateFormat sdfLongU = new SimpleDateFormat("MMM dd,yyyy", Locale.ENGLISH);
    static SimpleDateFormat sdfLongTime = new SimpleDateFormat("yyyyMMddHHmmss");
    static SimpleDateFormat sdfLongTimePlus = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    static SimpleDateFormat sdfLongTimePlusSecond = new SimpleDateFormat("HH:mm:ss");
    static SimpleDateFormat sdfShortLongTimePlusCn = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
    static SimpleDateFormat sdfShortLongTimePlusCn2 = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
    static SimpleDateFormat sdfLongTimePlusMill = new SimpleDateFormat("yyyyMMddHHmmssSSSS");
    static SimpleDateFormat sdfMd = new SimpleDateFormat("MM月dd日");
    static SimpleDateFormat sdfMdHourMinute = new SimpleDateFormat("MM月dd日 HH时mm分");
    private static long DAY_IN_MILLISECOND = 0x5265c00L;
 
    public DateUtil() {
    }
 
    public static Date StringToDate2(String DATE) {
        if(StringUtils.isBlank(DATE)){
            return null;
        }
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date dt1 = null;
        try {
            dt1 = df.parse(DATE);
        } catch (Exception exception) {
            exception.printStackTrace();
        }
        return dt1;
    }
 
    /**
     * @author Pablo Descrption:ȡ�õ�ǰ����getgetg get Date format
     *         Example:2008-05-15
     * @return String
     * @throws Exception
     */
    public static String getDateLong(Date date) {
        String nowDate = "";
        try {
            if (date != null)
                nowDate = sdfLong.format(date);
            return nowDate;
        } catch (Exception e) {
            System.out.println("Error at getDate:" + e.getMessage());
            return "";
        }
    }
 
    public static String getDateLongSlash(Date date) {
        String nowDate = "";
        try {
            if (date != null)
                nowDate = sdfLongSlash.format(date);
            return nowDate;
        } catch (Exception e) {
            System.out.println("Error at getDate:" + e.getMessage());
            return "";
        }
    }
 
    /**
     * 得出两个日期之间的间隔小时
     *
     * @param fromDate
     *            格式为yyyy-MM-dd
     * @param toDate
     *            格式为yyyy-MM-dd
     * @return int
     */
    public static long getBetweenHours(Date fromDate, Date toDate) {
        long m_intervalday = 0;// 初始化时间间隔的值为0
        // 使用的时间格式为yyyy-MM-dd
        try {
            m_intervalday = toDate.getTime() - fromDate.getTime();// 计算所得为微秒数
            m_intervalday = m_intervalday / 1000 / 60 / 60;// 计算所得的天数
 
            return m_intervalday + 1;
        } catch (Exception e) {
            return Integer.MIN_VALUE;
        }
    }
 
    /**
     * @author Pablo Descrption:ȡ�õ�ǰ����getgetg get Date format
     *         Example:2008.03.15
     * @return String
     * @throws Exception
     */
    public static String getDateShortPoint(Date date) {
        String nowDate = "";
        try {
            if (date != null)
                nowDate = sdfShortPoint.format(date);
            return nowDate;
        } catch (Exception e) {
            System.out.println("Error at getDate:" + e.getMessage());
            return "";
        }
    }
 
    public static int getDateNum(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        try {
            return calendar.get(Calendar.DAY_OF_MONTH);
        } catch (Exception e) {
            System.out.println("Error at getDate:" + e.getMessage());
            return 0;
        }
    }
 
    /**
     * @author Pablo Descrption:ȡ�õ�ǰ����getgetg get Date format
     *         Example:2008年-05月-15日
     * @return String
     * @throws Exception
     */
    public static String getDateLongCn(Date date) {
        String nowDate = "";
        try {
            if (date != null)
                nowDate = sdfLongCn.format(date);
            return nowDate;
        } catch (Exception e) {
            System.out.println("Error at getDate:" + e.getMessage());
            return "";
        }
    }
 
    /**
     * @author vowo Descrption:ȡ�õ�ǰ����getgetg get Date format Example:05月-15日
     * @return String
     * @throws Exception
     */
    public static String getDateMD(Date date) {
        String nowDate = "";
        try {
            if (date != null)
                nowDate = sdfMd.format(date);
            return nowDate;
        } catch (Exception e) {
            System.out.println("Error at getDate:" + e.getMessage());
            return "";
        }
    }
 
    /**
     * @author Pablo Descrption:ȡ�õ�ǰ����getgetg get Date format
     *         Example:2008年-05月-15日 11:05
     * @return String
     * @throws Exception
     */
    public static String getDateShortLongTimeCn(Date date) {
        String nowDate = "";
        try {
            if (date != null)
                nowDate = sdfShortLongTimePlusCn.format(date);
            return nowDate;
        } catch (Exception e) {
            System.out.println("Error at getDate:" + e.getMessage());
            return "";
        }
    }
 
    /**
     * @author Pablo Descrption:ȡ�õ�ǰ����getgetg get Date format Example:Aug 28,
     *         2007
     * @return String
     * @throws Exception
     */
    public static String getDateUS(Date date) {
        String nowDate = "";
        try {
            if (date != null)
                nowDate = sdfLongU.format(date);
            return nowDate;
        } catch (Exception e) {
            System.out.println("Error at getDate:" + e.getMessage());
            return "";
        }
    }
 
    /**
     * @author Pablo Descrption:ȡ�õ�ǰ����getgetg get Date format Example:Aug 28,
     *         2007
     * @return String
     * @throws Exception
     */
    public static String getDateUSShort(Date date) {
        String nowDate = "";
        try {
            if (date != null)
                nowDate = sdfShortU.format(date);
            return nowDate;
        } catch (Exception e) {
            System.out.println("Error at getDate:" + e.getMessage());
            return "";
        }
    }
 
    /**
     * 简单转换日期类型到字符串类型,本地信息设为UK
     *
     * @param date
     * @param format
     * @return String
     */
    public static String getFomartDate(Date date, String format) {
        try {
            return new SimpleDateFormat(format, Locale.UK).format(date);
        } catch (Exception e) {
            e.printStackTrace();
            return (date == null) ? new Date().toString() : date.toString();
        }
    }
 
    /**
     * Descrption:取得当前日期时间,格式为:YYYYMMDDHHMISS
     *
     * @return String
     * @throws Exception
     */
    public static String getNowLongTime() throws Exception {
        String nowTime = "";
        try {
            java.sql.Date date = null;
            date = new java.sql.Date(new Date().getTime());
            nowTime = sdfLongTime.format(date);
            return nowTime;
        } catch (Exception e) {
            throw e;
        }
    }
 
    /**
     * Descrption:取得当前日期时间,格式为:MM月dd日 HH时mm分
     *
     * @return String
     * @throws Exception
     */
    public static String getHourMinute(Date date) throws Exception {
        String nowTime = "";
        try {
            if (date != null) {
                nowTime = sdfMdHourMinute.format(date);
            }
            return nowTime;
        } catch (Exception e) {
            throw e;
        }
    }
 
    /**
     * Descrption:取得当前日期,格式为:YYYYMMDD
     *
     * @return String
     * @throws Exception
     */
    public static String getNowShortDate() throws Exception {
        String nowDate = "";
        try {
            java.sql.Date date = null;
            date = new java.sql.Date(new Date().getTime());
            nowDate = sdfShort.format(date);
            return nowDate;
        } catch (Exception e) {
            throw e;
        }
    }
    public static String getShortDateStr(Date date)   {
        String nowDate = "";
        try {
            nowDate = sdfShort.format(date);
            return nowDate;
        } catch (Exception e) {
           return  null;
        }
    }
 
    /**
     * Descrption:取得当前日期,格式为:YYYY-MM-DD
     *
     * @return String
     * @throws Exception
     */
    public static String getNowFormateDate() throws Exception {
        String nowDate = "";
        try {
            java.sql.Date date = null;
            date = new java.sql.Date(new Date().getTime());
            nowDate = sdfLong.format(date);
            return nowDate;
        } catch (Exception e) {
            throw e;
        }
    }
 
    /**
     * Descrption:取得当前日期,格式为:yyyy-MM-dd HH:mm:ss
     *
     * @return String
     * @throws Exception
     */
    public static String getNowPlusTime() throws Exception {
        String nowDate = "";
        try {
            java.sql.Date date = null;
            date = new java.sql.Date(new Date().getTime());
            nowDate = sdfLongTimePlus.format(date);
            return nowDate;
        } catch (Exception e) {
            throw e;
        }
    }
 
    /**
     * Descrption:取得当前日期,格式为:yyyy-MM-dd HH:mm:ss
     *
     * @return String
     * @throws Exception
     */
    public static String getPlusTime(Date date) throws Exception {
        if (date == null)
            return null;
        try {
            String nowDate = sdfLongTimePlus.format(date);
            return nowDate;
        } catch (Exception e) {
            throw e;
        }
    }
 
    /**
     * Descrption:取得当前日期,格式为:yyyy-MM-dd HH:mm:ss
     *
     * @return String
     * @throws Exception
     */
    public static String getPlusTime2(Date date) {
 
        if (date == null)
            return "";
        try {
            String nowDate = sdfLongTimePlus.format(date);
            return nowDate;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }
 
    /**
     * Descrption:取得当前日期到毫秒极,格式为:yyyyMMddHHmmssSSSS
     *
     * @return String
     * @throws Exception
     */
    public static String getNowPlusTimeMill() throws Exception {
        String nowDate = "";
        try {
            java.sql.Date date = null;
            date = new java.sql.Date(new Date().getTime());
            nowDate = sdfLongTimePlusMill.format(date);
            return nowDate;
        } catch (Exception e) {
            throw e;
        }
    }
 
    /**
     * 得到当前年份值:1900
     *
     * @return String
     * @throws Exception
     */
    public static String getNowYear() throws Exception {
        String nowYear = "";
        try {
            String strTemp = getNowLongTime();
            nowYear = strTemp.substring(0, 4);
            return nowYear;
        } catch (Exception e) {
            throw e;
        }
    }
 
    /**
     * 得到当前月份值:12
     *
     * @return String
     * @throws Exception
     */
    public static String getNowMonth() throws Exception {
        String nowMonth = "";
        try {
            String strTemp = getNowLongTime();
            nowMonth = strTemp.substring(4, 6);
            return nowMonth;
        } catch (Exception e) {
            throw e;
        }
    }
 
    /**
     * 得到当前日期值:30
     *
     * @return String
     * @throws Exception
     */
    public static String getNowDay() throws Exception {
        String nowDay = "";
        try {
            String strTemp = getNowLongTime();
            nowDay = strTemp.substring(6, 8);
            return nowDay;
        } catch (Exception e) {
            throw e;
        }
    }
 
    /**
     * 得到当前小时值:23
     *
     * @return String
     * @throws Exception
     */
    public static String getNowHour() throws Exception {
        String nowHour = "";
        try {
            String strTemp = getNowPlusTimeMill();
            nowHour = strTemp.substring(8, 10);
            return nowHour;
        } catch (Exception e) {
            throw e;
        }
    }
 
    /**
     * 根据秒数返回时分秒
     *
     * @param _second
     *            秒数
     * @return String
     * @throws Exception
     */
    public static String getTimeBySecond(String _second) throws Exception {
        String returnTime = "";
        long longHour = 0;
        long longMinu = 0;
        long longSec = 0;
        try {
            longSec = Long.parseLong(_second);
            if (longSec == 0) {
                returnTime = "0时0分0秒";
                return returnTime;
            }
            longHour = longSec / 3600; // 取得小时数
            longSec = longSec % 3600; // 取得余下的秒
            longMinu = longSec / 60; // 取得分数
            longSec = longSec % 60; // 取得余下的秒
            returnTime = longHour + "时" + longMinu + "分" + longSec + "秒";
            return returnTime;
        } catch (Exception e) {
            throw e;
        }
    }
 
    /**
     * Descrption:取得当前日期,格式为:yyyy-MM-dd HH:mm:ss
     *
     * @return String
     * @throws Exception
     */
    public static String getPlusTimeSecond(Date date) throws Exception {
        if (date == null)
            return null;
        try {
            String nowDate = sdfLongTimePlusSecond.format(date);
            return nowDate;
        } catch (Exception e) {
            throw e;
        }
    }
 
    /**
     * pablo 根据毫秒数返回时分秒毫秒
     *
     * @param ms_second
     *            秒数
     * @return String
     * @throws Exception
     */
    public static String getTimeBySecond(long ms_second) throws Exception {
        String returnTime = "";
        long longHour = 0;
        long longMinu = 0;
        long longSec = 0;
        long longMs = ms_second;
        try {
            if (longMs == 0) {
                returnTime = "0时0分0秒0毫秒";
                return returnTime;
            }
            longHour = longMs / 3600000; // 取得小时数
            longMs = longMs % 3600000; // 取得余下的毫秒
            longMinu = longMs / 60000; // 取得分数
            longMs = longMs % 60000; // 取得余下的毫秒
            longSec = longMs / 1000; // 取得余下的秒
            longMs = longMs % 1000; // 取得余下的毫秒
            returnTime = longHour + "时" + longMinu + "分" + longSec + "秒" + longMs + "毫秒";
            return returnTime;
        } catch (Exception e) {
            throw e;
        }
    }
 
    /**
     * 得到日期中的年份
     *
     * @param date
     *            日期
     * @return yyyy格式的年份
     */
    public static int convertDateToYear(Date date) {
        SimpleDateFormat df = new SimpleDateFormat("yyyy", new DateFormatSymbols());
        return Integer.parseInt(df.format(date));
    }
 
    /**
     * 得到日期中年月组成的字符串
     *
     * @param d
     *            日期
     * @return yyyyMM格式的年月字符串
     */
    public static String convertDateToYearMonth(Date d) {
        SimpleDateFormat df = new SimpleDateFormat("yyyyMM", new DateFormatSymbols());
        return df.format(d);
    }
 
    /**
     * 得到日期中年月日组成的字符串
     *
     * @param d
     *            日期
     * @return yyyyMMdd格式的年月日字符串
     */
    public static String convertDateToYearMonthDay(Date d) {
        SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd", new DateFormatSymbols());
        return df.format(d);
    }
 
    /**
     * 得到日期中的月份
     *
     * @param d
     *            日期
     * @return yyyy格式的年份
     */
    public static String convertDateToMonth(Date d) {
        SimpleDateFormat df = new SimpleDateFormat("MM", new DateFormatSymbols());
        return df.format(d);
    }
 
    /**
     * 得到日期中的日
     *
     *            日期
     * @return yyyy格式的年份
     */
    public static String convertDateToDay(Date d) {
        SimpleDateFormat df = new SimpleDateFormat("dd", new DateFormatSymbols());
        return df.format(d);
    }
 
    /**
     * 得到日期中的小时
     *
     *            日期
     * @return HH格式的小时
     */
    public static String convertDateToHour(Date d) {
        SimpleDateFormat df = new SimpleDateFormat("HH", new DateFormatSymbols());
        return df.format(d);
    }
 
    /**
     * 得到日期中的分钟
     *
     * @param d
     *            日期
     * @return mm格式的分钟
     */
    public static String convertDateToMinute(Date d) {
        SimpleDateFormat df = new SimpleDateFormat("mm", new DateFormatSymbols());
        return df.format(d);
    }
 
    /**
     * 获取当前日期为日期型
     *
     * @return 当前日期,java.util.Date类型
     */
    public static Date getCurrentDate() {
        Calendar cal = Calendar.getInstance();
 
        // String currentDate = null;
        Date d = cal.getTime();
 
        return d;
    }
 
    /**
     * 获取当前日期为日期型
     *
     * @return 当前日期,java.util.Date类型
     */
    public static Date getCurrentDateDelay() {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.SECOND, 1);
        // String currentDate = null;
        Date d = cal.getTime();
 
        return d;
    }
 
    /**
     * 获取当前年月的字符串
     *
     * @return 当前年月,yyyyMM格式
     */
    public static String getCurrentYearMonth() {
        Calendar cal = Calendar.getInstance();
        String currentYear = (new Integer(cal.get(Calendar.YEAR))).toString();
        String currentMonth = null;
        if (cal.get(Calendar.MONTH) < 9)
            currentMonth = "0" + (new Integer(cal.get(Calendar.MONTH) + 1)).toString();
        else
            currentMonth = (new Integer(cal.get(Calendar.MONTH) + 1)).toString();
        return (currentYear + currentMonth);
    }
 
    /**
     * 获取当前年为整型
     *
     * @return 获取当前日期中的年,int型
     */
    public static int getCurrentYear() {
        Calendar cal = Calendar.getInstance();
        int currentYear = cal.get(Calendar.YEAR);
        return currentYear;
    }
 
    /**
     * 新增的格式化时间类,将时间进行标准化格式,适用于将前台传入的日期格式化为实际可行的日期
     * 如将20050600格式化为20050601,或将20050631格式化为20050630
     *
     * @param _dateTime
     *            传入的原时间串
     * @param _format
     *            格式符,YYYYMMDDHH24MISS,YYYYMMDDHH12MISS
     * @return String
     * @throws Exception
     */
    public static String formatDateTime(String _dateTime, String _format) throws Exception {
        String returnValue = "";
        String formatString = _format.toUpperCase();
        String strYear = "";
        String strMonth = "";
        String strDay = "";
        String strHour = "";
        String strMinu = "";
        String strSec = "";
        int hourType = 12; // 12小时制,24小时制
        int yearType = 1; // 1为平年,2为闰年
        try {
            if (formatString.indexOf("YYYY") >= 0) {
                int tempBeginPlace = formatString.indexOf("YYYY");
                int temEndPlace = tempBeginPlace + 4;
                strYear = _dateTime.substring(tempBeginPlace, temEndPlace);
            }
            if (formatString.indexOf("MM") >= 0) {
                int tempBeginPlace = formatString.indexOf("MM");
                int temEndPlace = tempBeginPlace + 2;
                strMonth = _dateTime.substring(tempBeginPlace, temEndPlace);
            }
            if (formatString.indexOf("DD") >= 0) {
                int tempBeginPlace = formatString.indexOf("DD");
                int temEndPlace = tempBeginPlace + 2;
                strDay = _dateTime.substring(tempBeginPlace, temEndPlace);
            }
            if (formatString.indexOf("HH24") >= 0) {
                int tempBeginPlace = formatString.indexOf("HH24");
                int temEndPlace = tempBeginPlace + 2;
                strHour = _dateTime.substring(tempBeginPlace, temEndPlace);
                formatString = formatString.replaceAll("24", "");
                // 为了保持位数一致,去除24
                hourType = 24;
            } else if (formatString.indexOf("HH12") >= 0) {
                int tempBeginPlace = formatString.indexOf("HH12");
                int temEndPlace = tempBeginPlace + 2;
                strHour = _dateTime.substring(tempBeginPlace, temEndPlace);
                formatString = formatString.replaceAll("12", "");
                // 为了保持位数一致,去除12
                hourType = 12;
            } else if (formatString.indexOf("HH") >= 0) {
                int tempBeginPlace = formatString.indexOf("HH");
                int temEndPlace = tempBeginPlace + 2;
                strHour = _dateTime.substring(tempBeginPlace, temEndPlace);
                hourType = 12; // 如果未指定小时制,则默认为12小时制;
            }
            if (formatString.indexOf("MI") >= 0) {
                int tempBeginPlace = formatString.indexOf("MI");
                int temEndPlace = tempBeginPlace + 2;
                strMinu = _dateTime.substring(tempBeginPlace, temEndPlace);
            }
            if (formatString.indexOf("SS") >= 0) {
                int tempBeginPlace = formatString.indexOf("SS");
                int temEndPlace = tempBeginPlace + 2;
                strSec = _dateTime.substring(tempBeginPlace, temEndPlace);
            }
 
            // 判断是否是闰年
            if (!strYear.equals("")) {
                int intYear = Integer.parseInt(strYear);
                // 能被4整除,但不能被100整除② 能被4整除,且能被400
                if (intYear % 4 == 0) {
                    if (intYear % 100 != 0) {
                        yearType = 2;
                    }
                }
                if (intYear % 4 == 0) {
                    if (intYear % 400 == 0) {
                        yearType = 2;
                    }
                }
            }
            // 格式化月
            if (!strMonth.equals("")) {
                int intMonth = Integer.parseInt(strMonth);
                if (intMonth == 0) {
                    strMonth = "01";
                    intMonth = 1;
                }
                if (intMonth > 12) {
                    strMonth = "12";
                    intMonth = 12;
                }
            }
 
            // 格式化日
            if (!strDay.equals("")) {
                int intDay = Integer.parseInt(strDay);
                if (intDay == 0) {
                    strDay = "01";
                    intDay = 1;
                }
                if (intDay > 31) {
                    strDay = "31";
                    intDay = 31;
                }
                if ((strMonth.equals("01")) || (strMonth.equals("03")) || (strMonth.equals("05"))
                        || (strMonth.equals("07")) || (strMonth.equals("08")) || (strMonth.equals("10"))
                        || (strMonth.equals("12"))) {
                    if (intDay > 31) {
                        strDay = "31";
                        intDay = 31;
                    }
                }
                if ((strMonth.equals("02")) || (strMonth.equals("04")) || (strMonth.equals("06"))
                        || (strMonth.equals("09")) || (strMonth.equals("11"))) {
                    if (intDay > 30) {
                        strDay = "30";
                        intDay = 30;
                    }
                    if (strMonth.equals("02")) { // 对2月的特别处理
                        if (yearType == 2) {
                            if (intDay > 29) {
                                strDay = "29";
                                intDay = 29;
                            }
                        } else {
                            if (intDay > 28) {
                                strDay = "28";
                                intDay = 28;
                            }
                        }
                    }
                }
 
                // 格式化小时
                if (!strHour.equals("")) {
                    int intHour = Integer.parseInt(strHour);
                    if (intHour > 24) {
                        strHour = "24";
                        intHour = 24;
                    }
                    if (hourType == 12) {
                        if (intHour == 0) {
                            intHour = 1;
                            strHour = "01";
                        }
                        if (intHour > 12) {
                            intHour = intHour - 12;
                            strHour = "0" + intHour;
                        }
                    } else {
                        if (intHour > 23) {
                            intHour = 23;
                            strHour = "23";
                        }
                    }
                }
                // 格式化分
                if (!strMinu.equals("")) {
                    int intMinu = Integer.parseInt(strMinu);
                    if (intMinu > 59) {
                        strMinu = "59";
                        intMinu = 59;
                    }
                }
                // 格式化秒
                if (!strSec.equals("")) {
                    int intSec = Integer.parseInt(strSec);
                    if (intSec > 59) {
                        strSec = "59";
                        intSec = 59;
                    }
                }
            }
            returnValue = strYear + strMonth + strDay + strHour + strMinu + strSec;
            return returnValue;
        } catch (Exception e) {
            throw e;
        }
    }
 
    /**
     * 将指定格式的字符串转换为日期型
     *
     * @param strDate
     *            - 日期
     * @param oracleFormat
     *            --oracle型日期格式
     * @return 转换得到的日期
     */
    @SuppressWarnings("unchecked")
    public static Date stringToDate(String strDate, String oracleFormat) {
        if (strDate == null)
            return null;
        Hashtable<Integer, String> h = new Hashtable<Integer, String>();
        String javaFormat = new String();
        String s = oracleFormat.toLowerCase();
        if (s.indexOf("yyyy") != -1)
            h.put(new Integer(s.indexOf("yyyy")), "yyyy");
        else if (s.indexOf("yy") != -1)
            h.put(new Integer(s.indexOf("yy")), "yy");
        if (s.indexOf("mm") != -1)
            h.put(new Integer(s.indexOf("mm")), "MM");
 
        if (s.indexOf("dd") != -1)
            h.put(new Integer(s.indexOf("dd")), "dd");
        if (s.indexOf("hh24") != -1)
            h.put(new Integer(s.indexOf("hh24")), "HH");
        if (s.indexOf("mi") != -1)
            h.put(new Integer(s.indexOf("mi")), "mm");
        if (s.indexOf("ss") != -1)
            h.put(new Integer(s.indexOf("ss")), "ss");
 
        int intStart = 0;
        while (s.indexOf("-", intStart) != -1) {
            intStart = s.indexOf("-", intStart);
            h.put(new Integer(intStart), "-");
            intStart++;
        }
 
        intStart = 0;
        while (s.indexOf("/", intStart) != -1) {
            intStart = s.indexOf("/", intStart);
            h.put(new Integer(intStart), "/");
            intStart++;
        }
 
        intStart = 0;
        while (s.indexOf(" ", intStart) != -1) {
            intStart = s.indexOf(" ", intStart);
            h.put(new Integer(intStart), " ");
            intStart++;
        }
 
        intStart = 0;
        while (s.indexOf(":", intStart) != -1) {
            intStart = s.indexOf(":", intStart);
            h.put(new Integer(intStart), ":");
            intStart++;
        }
 
        if (s.indexOf("年") != -1)
            h.put(new Integer(s.indexOf("年")), "年");
        if (s.indexOf("月") != -1)
            h.put(new Integer(s.indexOf("月")), "月");
        if (s.indexOf("日") != -1)
            h.put(new Integer(s.indexOf("日")), "日");
        if (s.indexOf("时") != -1)
            h.put(new Integer(s.indexOf("时")), "时");
        if (s.indexOf("分") != -1)
            h.put(new Integer(s.indexOf("分")), "分");
        if (s.indexOf("秒") != -1)
            h.put(new Integer(s.indexOf("秒")), "秒");
 
        int i = 0;
        while (h.size() != 0) {
            Enumeration e = h.keys();
            int n = 0;
            while (e.hasMoreElements()) {
                i = ((Integer) e.nextElement()).intValue();
                if (i >= n)
                    n = i;
            }
            String temp = (String) h.get(new Integer(n));
            h.remove(new Integer(n));
 
            javaFormat = temp + javaFormat;
        }
        SimpleDateFormat df = new SimpleDateFormat(javaFormat);
 
        Date myDate = new Date();
        try {
            myDate = df.parse(strDate);
        } catch (Exception e) {
            // e.printStackTrace();
            return null;
        }
 
        return myDate;
    }
 
    public static Date StringToDate(String DATE1) {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        Date dt1 = null;
        try {
            dt1 = df.parse(DATE1);
        } catch (Exception exception) {
            exception.printStackTrace();
        }
        return dt1;
    }
 
    /**
     * 获取输入格式的日期字符串,字符串遵循Oracle格式
     *
     * @param d
     *            - 日期
     * @param format
     *            - 指定日期格式,格式的写法为Oracle格式
     * @return 按指定的日期格式转换后的日期字符串
     */
    public static String dateToString(Date d, String format) {
        if (d == null)
            return "";
        Hashtable<Integer, String> h = new Hashtable<Integer, String>();
        String javaFormat = new String();
        String s = format.toLowerCase();
        if (s.indexOf("yyyy") != -1)
            h.put(new Integer(s.indexOf("yyyy")), "yyyy");
        else if (s.indexOf("yy") != -1)
            h.put(new Integer(s.indexOf("yy")), "yy");
        if (s.indexOf("mm") != -1)
            h.put(new Integer(s.indexOf("mm")), "MM");
 
        if (s.indexOf("dd") != -1)
            h.put(new Integer(s.indexOf("dd")), "dd");
        if (s.indexOf("hh24") != -1)
            h.put(new Integer(s.indexOf("hh24")), "HH");
        if (s.indexOf("mi") != -1)
            h.put(new Integer(s.indexOf("mi")), "mm");
        if (s.indexOf("ss") != -1)
            h.put(new Integer(s.indexOf("ss")), "ss");
 
        int intStart = 0;
        while (s.indexOf("-", intStart) != -1) {
            intStart = s.indexOf("-", intStart);
            h.put(new Integer(intStart), "-");
            intStart++;
        }
 
        intStart = 0;
        while (s.indexOf("/", intStart) != -1) {
            intStart = s.indexOf("/", intStart);
            h.put(new Integer(intStart), "/");
            intStart++;
        }
 
        intStart = 0;
        while (s.indexOf(" ", intStart) != -1) {
            intStart = s.indexOf(" ", intStart);
            h.put(new Integer(intStart), " ");
            intStart++;
        }
 
        intStart = 0;
        while (s.indexOf(":", intStart) != -1) {
            intStart = s.indexOf(":", intStart);
            h.put(new Integer(intStart), ":");
            intStart++;
        }
 
        if (s.indexOf("年") != -1)
            h.put(new Integer(s.indexOf("年")), "年");
        if (s.indexOf("月") != -1)
            h.put(new Integer(s.indexOf("月")), "月");
        if (s.indexOf("日") != -1)
            h.put(new Integer(s.indexOf("日")), "日");
        if (s.indexOf("时") != -1)
            h.put(new Integer(s.indexOf("时")), "时");
        if (s.indexOf("分") != -1)
            h.put(new Integer(s.indexOf("分")), "分");
        if (s.indexOf("秒") != -1)
            h.put(new Integer(s.indexOf("秒")), "秒");
 
        int i = 0;
        while (h.size() != 0) {
            Enumeration<Integer> e = h.keys();
            int n = 0;
            while (e.hasMoreElements()) {
                i = ((Integer) e.nextElement()).intValue();
                if (i >= n)
                    n = i;
            }
            String temp = (String) h.get(new Integer(n));
            h.remove(new Integer(n));
 
            javaFormat = temp + javaFormat;
        }
        SimpleDateFormat df = new SimpleDateFormat(javaFormat, new DateFormatSymbols());
 
        return df.format(d);
    }
 
    /**
     * 获取输入格式的日期字符串,字符串遵循Oracle格式
     *
     * @param d
     *            - 日期
     * @param format
     *            - 指定日期格式,格式的写法为Oracle格式
     * @return 按指定的日期格式转换后的日期字符串
     */
    public static String getDate(Date d, String format) {
        if (d == null)
            return "";
        Hashtable<Integer, String> h = new Hashtable<Integer, String>();
        String javaFormat = new String();
        String s = format.toLowerCase();
        if (s.indexOf("yyyy") != -1)
            h.put(new Integer(s.indexOf("yyyy")), "yyyy");
        else if (s.indexOf("yy") != -1)
            h.put(new Integer(s.indexOf("yy")), "yy");
        if (s.indexOf("mm") != -1)
            h.put(new Integer(s.indexOf("mm")), "MM");
 
        if (s.indexOf("dd") != -1)
            h.put(new Integer(s.indexOf("dd")), "dd");
        if (s.indexOf("hh24") != -1)
            h.put(new Integer(s.indexOf("hh24")), "HH");
        if (s.indexOf("mi") != -1)
            h.put(new Integer(s.indexOf("mi")), "mm");
        if (s.indexOf("ss") != -1)
            h.put(new Integer(s.indexOf("ss")), "ss");
 
        int intStart = 0;
        while (s.indexOf("-", intStart) != -1) {
            intStart = s.indexOf("-", intStart);
            h.put(new Integer(intStart), "-");
            intStart++;
        }
 
        intStart = 0;
        while (s.indexOf("/", intStart) != -1) {
            intStart = s.indexOf("/", intStart);
            h.put(new Integer(intStart), "/");
            intStart++;
        }
 
        intStart = 0;
        while (s.indexOf(" ", intStart) != -1) {
            intStart = s.indexOf(" ", intStart);
            h.put(new Integer(intStart), " ");
            intStart++;
        }
 
        intStart = 0;
        while (s.indexOf(":", intStart) != -1) {
            intStart = s.indexOf(":", intStart);
            h.put(new Integer(intStart), ":");
            intStart++;
        }
 
        if (s.indexOf("年") != -1)
            h.put(new Integer(s.indexOf("年")), "年");
        if (s.indexOf("月") != -1)
            h.put(new Integer(s.indexOf("月")), "月");
        if (s.indexOf("日") != -1)
            h.put(new Integer(s.indexOf("日")), "日");
        if (s.indexOf("时") != -1)
            h.put(new Integer(s.indexOf("时")), "时");
        if (s.indexOf("分") != -1)
            h.put(new Integer(s.indexOf("分")), "分");
        if (s.indexOf("秒") != -1)
            h.put(new Integer(s.indexOf("秒")), "秒");
 
        int i = 0;
        while (h.size() != 0) {
            Enumeration<Integer> e = h.keys();
            int n = 0;
            while (e.hasMoreElements()) {
                i = ((Integer) e.nextElement()).intValue();
                if (i >= n)
                    n = i;
            }
            String temp = (String) h.get(new Integer(n));
            h.remove(new Integer(n));
 
            javaFormat = temp + javaFormat;
        }
        SimpleDateFormat df = new SimpleDateFormat(javaFormat, new DateFormatSymbols());
 
        return df.format(d);
    }
 
    /**
     * 根据身份证号码获取年龄
     *
     * @param id
     *            身份证号
     * @throws Exception
     *             身份证号错误时发生
     * @return int - 年龄
     */
    public static int getAge(String id) throws Exception {
        int age = -1;
        int length = id.length();
        String birthday = "";
        if (length == 15) {
            birthday = id.substring(6, 8);
            birthday = "19" + birthday;
        } else if (length == 18) {
            birthday = id.substring(6, 10);
        } else {
            throw new Exception("错误的身份证号");
        }
        int currentYear = Calendar.getInstance().get(Calendar.YEAR);
        age = currentYear - (new Integer(birthday)).intValue();
        return age;
    }
 
    /**
     * 根据年龄获取出生年份
     *
     * @param age
     *            int 年龄
     * @return Date - 出生年份
     */
    public static java.sql.Date getDateByAge(int age) {
        Calendar calendar = Calendar.getInstance(Locale.CHINESE);
        @SuppressWarnings("unused")
        long current = calendar.getTimeInMillis();
        calendar.set(calendar.get(Calendar.YEAR) - age, calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE));
        return new java.sql.Date((calendar.getTimeInMillis()));
    }
 
    /**
     * 比较两个日期(年月型,格式为YYYYMM)之间相差月份
     *
     * @param dealMonth
     *            - 开始年月
     * @param alterMonth
     *            - 结束年月
     * @return alterMonth-dealMonth相差的月数
     */
    public static int calBetweenTwoMonth(String dealMonth, String alterMonth) {
        int length = 0;
        if ((dealMonth.length() != 6) || (alterMonth.length() != 6)) {
            // 比较年月字符串的长度不正确
            length = -1;
 
        } else {
            int dealInt = Integer.parseInt(dealMonth);
            int alterInt = Integer.parseInt(alterMonth);
            if (dealInt < alterInt) {
                // 第一个年月变量应大于或等于第二个年月变量
                length = -2;
            } else {
                int dealYearInt = Integer.parseInt(dealMonth.substring(0, 4));
                int dealMonthInt = Integer.parseInt(dealMonth.substring(4, 6));
                int alterYearInt = Integer.parseInt(alterMonth.substring(0, 4));
                int alterMonthInt = Integer.parseInt(alterMonth.substring(4, 6));
                length = (dealYearInt - alterYearInt) * 12 + (dealMonthInt - alterMonthInt);
            }
        }
        return length;
    }
 
    /**
     * 得到两个日期之间相差的天数
     *
     * @param newDate
     *            大的日期
     * @param oldDate
     *            小的日期
     * @return newDate-oldDate相差的天数
     */
    public static int daysBetweenDates(Date newDate, Date oldDate) {
        long days = 0;
        try {
            long nDay = 0;
            long oldDay = 0;
            if (oldDate == null) {
                oldDay = 0;
            } else {
                oldDay = oldDate.getTime();
            }
            if (newDate == null) {
                nDay = 0;
            } else {
                nDay = newDate.getTime();
            }
            days = (nDay - oldDay) / 1000 / 60 / 60 / 24;
        } catch (Exception e) {
            // TODO: handle exception
        }
 
        return (int) days;
    }
 
    public static int daysBetweenDates11(Date newDate, Date oldDate) {
        int days = 0;
        Calendar calo = Calendar.getInstance();
        Calendar caln = Calendar.getInstance();
        calo.setTime(oldDate);
        caln.setTime(newDate);
        int oday = calo.get(Calendar.DAY_OF_YEAR);
        int nyear = caln.get(Calendar.YEAR);
        int oyear = calo.get(Calendar.YEAR);
        while (nyear > oyear) {
            calo.set(Calendar.MONTH, 11);
            calo.set(Calendar.DATE, 31);
            days = days + calo.get(Calendar.DAY_OF_YEAR);
            oyear = oyear + 1;
            calo.set(Calendar.YEAR, oyear);
        }
        int nday = caln.get(Calendar.DAY_OF_YEAR);
        days = days + nday - oday;
 
        return days;
    }
 
    /**
     * 取得与原日期相差一定天数的日期,返回Date型日期
     *
     * @param date
     *            原日期
     * @param intBetween
     *            相差的天数
     * @return date加上intBetween天后的日期
     */
    public static Date getDateBetween(Date date, int intBetween) {
        Calendar calo = Calendar.getInstance();
        calo.setTime(date);
        calo.add(Calendar.DATE, intBetween);
        return calo.getTime();
    }
 
    /**
     * 按指定格式取得与原日期相差一定天数的日期,返回String型日期
     *
     * @param date
     *            原日期
     * @param intBetween
     *            相差的日期
     * @param strFromat
     *            返回日期的格式
     * @return date加上intBetween天后的日期
     */
    public static String getDateBetween_String(Date date, int intBetween, String strFromat) {
        Date dateOld = getDateBetween(date, intBetween);
        return getDate(dateOld, strFromat);
    }
 
    /**
     * 得到将年月型字符串增加1月后的日期字符串
     *
     * @param yearMonth
     *            yyyyMM格式
     * @return yearMonth增加一个月后的日期,yyyyMM格式
     */
    public static String increaseYearMonth(String yearMonth) {
        int year = (new Integer(yearMonth.substring(0, 4))).intValue();
        int month = (new Integer(yearMonth.substring(4, 6))).intValue();
        month = month + 1;
        if (month <= 12 && month >= 10)
        {
            return yearMonth.substring(0, 4) + (new Integer(month)).toString();
        }
        else if (month < 10)
        {
            return yearMonth.substring(0, 4) + "0" + (new Integer(month)).toString();
        }
        else{
            // if(month>12)
            return (new Integer(year + 1)).toString() + "0" + (new Integer(month - 12)).toString();
        }
 
    }
 
    /**
     * 得到将年月型字符串增加指定月数后的日期字符串
     *
     * @param yearMonth
     *            yyyyMM格式日期
     * @param addMonth
     *            增加指定月数
     * @return yearMonth 增加addMonth个月后的日期,yyyyMM格式
     */
    public static String increaseYearMonth(String yearMonth, int addMonth) {
        int year = (new Integer(yearMonth.substring(0, 4))).intValue();
        int month = (new Integer(yearMonth.substring(4, 6))).intValue();
        month = month + addMonth;
        year = year + month / 12;
        month = month % 12;
        if (month <= 12 && month >= 10)
            return year + (new Integer(month)).toString();
        else
            return year + "0" + (new Integer(month)).toString();
 
    }
 
    /**
     * 得到将年月型字符串减去1月后的日期字符串
     *
     * @param yearMonth
     *            - yyyyMM格式
     * @return - yearMonth减少一个月的日期,yyyyMM格式
     */
    public static String descreaseYearMonth(String yearMonth) {
        int year = (new Integer(yearMonth.substring(0, 4))).intValue();
        int month = (new Integer(yearMonth.substring(4, 6))).intValue();
        month = month - 1;
        if (month >= 10)
        {
            return yearMonth.substring(0, 4) + (new Integer(month)).toString();
        }
        else if (month > 0 && month < 10)
        {
            return yearMonth.substring(0, 4) + "0" + (new Integer(month)).toString();
        }
        else
        {
            // if(month>12)
            return (new Integer(year - 1)).toString() + (new Integer(month + 12)).toString();
        }
 
    }
 
    /**
     * 得到将年月型字符串减去1月后的日期字符串
     *
     * @param yearMonthDay
     *            - yyyy-MM-dd格式
     * @return - yearMonth减少一个月的日期,yyyy-MM-dd格式
     */
    public static String descreaseYearMonth2(String yearMonthDay) {
        int year = (new Integer(yearMonthDay.substring(0, 4))).intValue();
        int month = (new Integer(yearMonthDay.substring(5, 7))).intValue();
        String dd = yearMonthDay.substring(8, 10);
        month = month - 1;
        if (month >= 10)
            return yearMonthDay.substring(0, 4) + "-" + (new Integer(month)).toString() + "-" + dd;
        else if (month > 0 && month < 10)
            return yearMonthDay.substring(0, 4) + "0" + "-" + (new Integer(month)).toString() + "-" + dd;
        else
            return (new Integer(year - 1)).toString() + "-" + (new Integer(month + 12)).toString() + "-" + dd;
 
    }
 
    /**
     * 比较两个年月型日期的大小,日期格式为yyyyMM 两个字串6位,前4代表年,后2代表月, <br>
     * IF 第一个代表的时间 > 第二个代表的时间,返回真,ELSE 返回假 <br>
     *
     * @param s1
     *            日期1
     * @param s2
     *            日期2
     * @return boolean 如果s1大于等于s2则返回真,否则返回假
     */
    public static boolean yearMonthGreatEqual(String s1, String s2) {
        String temp1 = s1.substring(0, 4);
        String temp2 = s2.substring(0, 4);
        String temp3 = s1.substring(4, 6);
        String temp4 = s2.substring(4, 6);
 
        if (Integer.parseInt(temp1) > Integer.parseInt(temp2))
            return true;
        else if (Integer.parseInt(temp1) == Integer.parseInt(temp2)) {
            if (Integer.parseInt(temp3) >= Integer.parseInt(temp4))
                return true;
            else
                return false;
        } else
            return false;
    }
 
    /**
     * 比较两个年月型日期的大小,日期格式为yyyyMM 两个字串6位,前4代表年,后2代表月, <br>
     * IF 第一个代表的时间 > 第二个代表的时间,返回真,ELSE 返回假 <br>
     *
     * @param s1
     *            日期1
     * @param s2
     *            日期2
     * @return boolean 如果s1大于s2则返回真,否则返回假
     */
    public static boolean yearMonthGreater(String s1, String s2) {
        String temp1 = s1.substring(0, 4);
        String temp2 = s2.substring(0, 4);
        String temp3 = s1.substring(4, 6);
        String temp4 = s2.substring(4, 6);
 
        if (Integer.parseInt(temp1) > Integer.parseInt(temp2))
            return true;
        else if (Integer.parseInt(temp1) == Integer.parseInt(temp2)) {
            if (Integer.parseInt(temp3) > Integer.parseInt(temp4))
                return true;
            else
                return false;
        } else
            return false;
    }
 
    /**
     * 将日期型数据转换成Oracle要求的标准格式的字符串
     *
     * @param date
     *            日期
     * @return 格式化后的字符串
     */
    public static String getOracleFormatDateStr(Date date) {
        return getDate(date, "YYYY-MM-DD HH24:MI:SS");
    }
 
    /**
     * 字串6位,前4代表年,后2代表月, 返回给定日期中的月份中的最后一天 param term(YYYYMMDD)
     *
     * @param term
     *            - 年月,格式为yyyyMM
     * @return String 指定年月中该月份的天数
     */
    public static String getLastDay(String term) {
 
        int getYear = Integer.parseInt(term.substring(0, 4));
        int getMonth = Integer.parseInt(term.substring(4, 6));
 
        String getLastDay = "";
 
        if (getMonth == 2) {
            if (getYear % 4 == 0 && getYear % 100 != 0 || getYear % 400 == 0) {
                getLastDay = "29";
            } else {
                getLastDay = "28";
            }
        } else if (getMonth == 4 || getMonth == 6 || getMonth == 9 || getMonth == 11) {
            getLastDay = "30";
        } else {
            getLastDay = "31";
        }
        return String.valueOf(getYear) + "年" + String.valueOf(getMonth) + "月" + getLastDay + "日";
    }
 
    /**
     * 返回两个年月(例如:200206)之间相差的月数,年月格式为yyyyMM
     *
     * @param strDateBegin
     *            - String
     * @param strDateEnd
     *            String
     * @return String strDateEnd-strDateBegin相差的月数
     */
    public static String getMonthBetween(String strDateBegin, String strDateEnd) {
        try {
            int intMonthBegin;
            int intMonthEnd;
            String strOut;
            if (strDateBegin.equals("") || strDateEnd.equals("") || strDateBegin.length() != 6
                    || strDateEnd.length() != 6)
            {
                strOut = "";
            }
            else {
                intMonthBegin = Integer.parseInt(strDateBegin.substring(0, 4)) * 12
                        + Integer.parseInt(strDateBegin.substring(4, 6));
                intMonthEnd = Integer.parseInt(strDateEnd.substring(0, 4)) * 12
                        + Integer.parseInt(strDateEnd.substring(4, 6));
                strOut = String.valueOf(intMonthBegin - intMonthEnd);
            }
            return strOut;
        } catch (Exception e) {
            return "0";
        }
    }
 
    /**
     * 将yyyyMMDD格式的日期转换为yyyy-MM-DD格式的日期 返回带'-'的日期(例如:20020612 转换为 2002-06-12)
     *
     * @param strDate
     *            String yyyyMMDD格式的日期
     * @return String - yyyy-MM-DD格式的日期
     */
    public static String getStrHaveAcross(String strDate) {
        try {
            return strDate.substring(0, 4) + "-" + strDate.substring(4, 6) + "-" + strDate.substring(6, 8);
        } catch (Exception e) {
            return strDate;
        }
    }
 
    /**
     * 取得当前日期的下一个月的第一天 add by yaojp 2002-10-08
     *
     * @return 当前日期的下个月的第一天,格式为yyyyMMDD
     */
    public static String getFirstDayOfNextMonth() {
        try {
            return increaseYearMonth(getNowShortDate().substring(0, 6)) + "01";
        } catch (Exception e) {
            return "";
        }
    }
 
    /**
     * 取得当前日期的下一个月的第一天 add by zhouning 2006-09-13
     *
     * @return 当前日期的下个月的第一天,格式为yyyyMMDD
     */
    public static String getFirstDayOfThisMonth() {
        try {
            return getNowShortDate().substring(0, 6) + "01";
        } catch (Exception e) {
            return "";
        }
    }
 
    /**
     * 将yyyyMM各式转换成yyyy年MM月格式
     *
     * @param yearMonth
     *            年月类型的字符串
     * @return String
     */
    public static String getYearAndMonth(String yearMonth) {
        if (null == yearMonth)
            return "";
        String ym = yearMonth.trim();
        if (6 != ym.length())
            return ym;
        String year = ym.substring(0, 4);
        String month = ym.substring(4);
        return new StringBuffer(year).append("年").append(month).append("月").toString();
    }
    /**
     * 将yyyyMM各式转换成yyyy年MM月格式
     *
     * @param date
     *            年月类型的字符串
     * @return String
     */
    public static String getYear(Date date) {
        if (null == date)
        {
            return "";
        }
 
        String ym = getPlusTime2(date).trim();
        if (StringUtils.isBlank(ym))
        {
            return "";
        }
        String year = ym.substring(0, 4);
        return year;
    }
 
    /**
     * 将输入的Integer类型的月数转化成"X年X月"格式的字符串
     *
     * @param month
     *            Integer
     * @return String
     */
    public static String month2YearMonth(String month) {
        String yearMonth = "";
        int smonth = 0;
        int year = 0;
        int rmonth = 0;
 
        if ((null == month) || ("0".equals(month)) || "".equals(month.trim())) {
            return "0月";
        }
 
        smonth = Integer.parseInt(month);
        year = smonth / 12;
        rmonth = smonth % 12;
 
        if (year > 0) {
            yearMonth = year + "年";
        }
        if (rmonth > 0) {
            yearMonth += rmonth + "个月";
        }
 
        return yearMonth;
    }
 
    /**
     * 将yyyyMM各式转换成yyyy年MM月格式
     *
     * @param month
     *            月
     * @return 返回年月型格式的日期
     */
    public static String getYearMonthByMonth(String month) {
        if (null == month)
            return null;
        String ym = month.trim();
        if (6 != ym.length())
            return ym;
        String year = ym.substring(0, 4);
        @SuppressWarnings("unused")
        String month1 = ym.substring(4);
        return new StringBuffer(year).append("年").append(month).append("月").toString();
    }
 
    /**
     * 得到将date增加指定月数后的date
     *
     * @param date
     *            日期
     * @param intBetween
     *            增加的月份
     * @return date 加上intBetween月数后的日期
     */
    public static Date increaseMonth(Date date, int intBetween) {
        Calendar calo = Calendar.getInstance();
        calo.setTime(date);
        calo.add(Calendar.MONTH, intBetween);
        return calo.getTime();
    }
 
    /**
     * 得到将date增加指定天数后的date
     *
     * @param date
     *            日期
     * @param intBetween
     *            增加的天数
     * @return date 加上intBetween天数后的日期
     */
    public static Date increaseDay(Date date, int intBetween) {
        if (date == null) {
            return null;
        }
        Calendar calo = Calendar.getInstance();
        calo.setTime(date);
        calo.add(Calendar.DATE, intBetween);
        return calo.getTime();
    }
 
    /**
     * 得到将date增加指定年数后的date
     *
     * @param date
     *            日期
     * @param intBetween
     *            增加的年数
     * @return date加上intBetween年数后的日期
     */
    public static Date increaseYear(Date date, int intBetween) {
        Calendar calo = Calendar.getInstance();
        calo.setTime(date);
        calo.add(Calendar.YEAR, intBetween);
        return calo.getTime();
    }
 
    /**
     * 比较两个时间先后
     *
     * @param str1
     *            传入的字符串
     * @param str2
     *            传入的字符串
     * @return int negative integer, zero, or a positive integer as str1 is less
     *         than, equal to, or greater than str2
     */
    public static int compareDate(String str1, String str2) {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        Date date1 = null, date2 = null;
        try {
            date1 = formatter.parse(str1);
            date2 = formatter.parse(str2);
        } catch (ParseException ex) {
            ex.printStackTrace();
        }
        return date1.compareTo(date2);
    }
 
    /**
     * 比较两个时间先后
     *
     * @param date1
     *            传入的字符串
     * @param date2
     *            传入的字符串
     * @return int negative integer, zero, or a positive integer as str1 is less
     *         than, equal to, or greater than str2
     */
    public static int compareDate(Date date1, Date date2) {
        if (date1 == null && date2 == null) {
            return 0;
        }
        if (date1 == null) {
            return -1;
        }
        if (date2 == null) {
            return 1;
        }
 
        return date2.compareTo(date1);
    }
 
    public static int compare_date(Date dt1, Date dt2, Date dtime) {
        try {
            if (dtime.compareTo(dt1) >= 0 && dt2.compareTo(dtime) >= 0) {
                return 1;
            } else {
                return -1;
            }
        } catch (Exception exception) {
            exception.printStackTrace();
        }
        return 0;
    }
 
    public static int compareDate(String str1, Date date2) {
        Date date1 = getDateByString(str1);
        return date1.compareTo(date2);
    }
 
    public static int compareDate(String format, String str1, Date date2) {
 
        Date date1 = null;
        try {
            date1 = fromStringToDate(format, str1);
        } catch (ParseException e) {
            // TODO 自动生成 catch 块
            e.printStackTrace();
        }
        return date1.compareTo(date2);
    }
 
    /**
     * 根据传入的日期字符串转换成相应的日期对象,如果字符串为空或不符合日期格 式,则返回当前时间。
     *
     * @param strDate
     *            String 日期字符串
     * @return java.sql.Timestamp 日期对象
     */
    public static Timestamp getDateByString(String strDate) {
        if (strDate.trim().equals("")) {
            return new Timestamp(System.currentTimeMillis());
        }
        try {
            strDate = getFormattedDate(strDate, "yyyy-MM-dd HH:mm:ss") + ".000000000";
            return Timestamp.valueOf(strDate);
        } catch (Exception ex) {
            return new Timestamp(System.currentTimeMillis());
        }
    }
 
 
    // /**
    // * 根据参数名称,从request对象中取出该参数,并把该参数转换成GB2312编码的字符集。
    // * @param request 请求对象
    // * @param strParamName 参数名称
    // * @return java.sql.Date 转换后的参数值
    // * */
    // public static java.sql.Timestamp getDateFromReqParam(HttpServletRequest
    // request, String strParamName)
    // {
    // String strStr =
    // StringUtil.getNotNullStr(request.getParameter(strParamName));
    // return getDateByString(strStr);
    // }
    /**
     * 得到当前日期,格式yyyy-MM-dd。
     *
     * @return String 格式化的日期字符串
     */
    public static String getCurrDate() {
        return getFormattedDate(getDateByString(""));
    }
 
    /**
     * 得到当前日期,格式yyyy-MM-dd。
     *
     * @return String 格式化的日期字符串
     */
    public static String getToday() {
        Date cDate = new Date();
        SimpleDateFormat cSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        return cSimpleDateFormat.format(cDate);
    }
 
    /**
     * 得到当前日期,格式yyyy-MM-dd。
     *
     * @return String 格式化的日期字符串
     */
    public static String getYesterday() {
        Date cDate = new Date();
        cDate.setTime(cDate.getTime() - 24 * 3600 * 1000);
        SimpleDateFormat cSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        return cSimpleDateFormat.format(cDate);
    }
 
    /**
     * 得到当前日期,格式yyyy-MM-dd。
     *
     * @return String 格式化的日期字符串
     */
    public static String getTomorrow() {
        Date cDate = new Date();
        cDate.setTime(cDate.getTime() + 24 * 3600 * 1000);
        SimpleDateFormat cSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        return cSimpleDateFormat.format(cDate);
    }
 
    /**
     * 返回默认的功能生效的时间,1900/01/01。
     *
     * @return String 默认的实效时间字符串
     */
    public static String getDefaultValidDate() {
        return "1900-01-01";
    }
 
    /**
     * 返回默认的功能失效的时间,2099/12/31。
     *
     * @return String 默认的实效时间字符串
     */
    public static String getDefaultExpireDate() {
        return "2099-12-31";
    }
 
    /**
     * 得到当前日期时间,格式为yyyy-MM-dd hh:mm:ss.
     *
     * @return String
     */
    public static String getCurrDateTime() {
        Timestamp date = new Timestamp(System.currentTimeMillis());
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        return formatter.format(date);
    }
 
    /**
     * 得到指定的日期,如一年三个月零九天后(以yyyy/MM/dd格式显示)参数为("yyyy/MM/dd",1,3,9)
     *
     * @param strFormat
     *            strFormat
     * @param iYear
     *            iYear
     * @param iMonth
     *            iMonth
     * @param iDate
     *            iDate
     * @return String
     */
    public static String getSpecDate(String strFormat, int iYear, int iMonth, int iDate) {
        Calendar rightNow = Calendar.getInstance();
        rightNow.set(Calendar.YEAR, rightNow.get(Calendar.YEAR) + iYear);
        rightNow.set(Calendar.MONTH, rightNow.get(Calendar.MONTH) + iMonth);
        rightNow.set(Calendar.DATE, rightNow.get(Calendar.DATE) + iDate);
        SimpleDateFormat df = new SimpleDateFormat(strFormat);
        return df.format(rightNow.getTime());
    }
 
    /**
     * 对输入的日期字符串进行默认的格式yyyy-MM-dd HH:mm:ss转换。
     *
     * @param strDate
     *            String 需要进行格式化的日期字符串
     * @return String 经过格式化后的字符串
     */
    public static String getDefaultFormattedDate(String strDate) {
        return getFormattedDate(strDate, "yyyy-MM-dd HH:mm:ss");
    }
 
    /**
     * 对输入的日期进行默认的格式yyyy-MM-dd HH:mm:ss转换。
     *
     * @param dtDate
     *            需要进行格式化的日期
     * @return String 经过格式化后的字符串
     */
    public static String getDefaultFormattedDate(Timestamp dtDate) {
        return getFormattedDate(dtDate, "yyyy-MM-dd HH:mm:ss");
    }
 
    public static Timestamp getNullBirthDay() {
        return new Timestamp(0);
    }
 
    /**
     * 对输入的日期字符串按照默认的格式yyyy-MM-dd转换.
     *
     * @param strDate
     *            String 需要进行格式化的日期字符串
     * @return String 经过格式化后的字符串
     */
    public static String getFormattedDate(String strDate) {
        return getFormattedDate(strDate, "yyyy-MM-dd");
    }
 
    /**
     * 对输入的日期字符串进行格式化,如果输入的是0000/00/00 00:00:00则返回空串.
     *
     * @param strDate
     *            String 需要进行格式化的日期字符串
     * @param strFormatTo
     *            String 要转换的日期格式
     * @return String 经过格式化后的字符串
     */
    public static String getFormattedDate(String strDate, String strFormatTo) {
        if (strDate == null || strDate.trim().equals("")) {
            return "";
        }
        strDate = strDate.replace('/', '-');
        strFormatTo = strFormatTo.replace('/', '-');
        if (strDate.equals("0000-00-00 00:00:00") || strDate.equals("1800-01-01 00:00:00")) {
            return "";
        }
        String formatStr = strFormatTo; // "yyyyMMdd";
        if (strDate == null || strDate.trim().equals("")) {
            return "";
        }
        switch (strDate.trim().length()) {
            case 6:
                if (strDate.substring(0, 1).equals("0")) {
                    formatStr = "yyMMdd";
                } else {
                    formatStr = "yyyyMM";
                }
                break;
            case 8:
                formatStr = "yyyyMMdd";
                break;
            case 10:
                if (strDate.indexOf("-") == -1) {
                    formatStr = "yyyy/MM/dd";
                } else {
                    formatStr = "yyyy-MM-dd";
                }
                break;
            case 11:
                if (strDate.getBytes().length == 14) {
                    formatStr = "yyyy年MM月dd日";
                } else {
                    return "";
                }
            case 14:
                formatStr = "yyyyMMddHHmmss";
                break;
            case 19:
                if (strDate.indexOf("-") == -1) {
                    formatStr = "yyyy/MM/dd HH:mm:ss";
                } else {
                    formatStr = "yyyy-MM-dd HH:mm:ss";
                }
                break;
            case 21:
                if (strDate.indexOf("-") == -1) {
                    formatStr = "yyyy/MM/dd HH:mm:ss.S";
                } else {
                    formatStr = "yyyy-MM-dd HH:mm:ss.S";
                }
                break;
            default:
                return strDate.trim();
        }
        try {
            SimpleDateFormat formatter = new SimpleDateFormat(formatStr);
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(formatter.parse(strDate));
            formatter = new SimpleDateFormat(strFormatTo);
            return formatter.format(calendar.getTime());
        } catch (Exception e) {
            // Common.printLog("转换日期字符串格式时出错;" + e.getMessage());
            return "";
        }
    }
 
    /**
     * 对输入的日期按照默认的格式yyyy-MM-dd转换.
     *
     * @param dtDate
     *            需要进行格式化的日期字符串
     * @return String 经过格式化后的字符串
     */
    public static String getFormattedDate(Timestamp dtDate) {
        return getFormattedDate(dtDate, "yyyy-MM-dd");
    }
 
    /**
     * 对输入的日期进行格式化, 如果输入的日期是null则返回空串.
     *
     * @param dtDate
     *            java.sql.Timestamp 需要进行格式化的日期字符串
     * @param strFormatTo
     *            String 要转换的日期格式
     * @return String 经过格式化后的字符串
     */
    public static String getFormattedDate(Timestamp dtDate, String strFormatTo) {
        if (dtDate == null) {
            return "";
        }
        if (dtDate.equals(new Timestamp(0))) {
            return "";
        }
        strFormatTo = strFormatTo.replace('/', '-');
        try {
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy");
            if (Integer.parseInt(formatter.format(dtDate)) < 1900) {
                return "";
            } else {
                formatter = new SimpleDateFormat(strFormatTo);
                return formatter.format(dtDate);
            }
        } catch (Exception e) {
            // Common.printLog("转换日期字符串格式时出错;" + e.getMessage());
            return "";
        }
    }
 
    /**
     * 把秒数转换成hh:mm:ss格式
     *
     * @param lSecond
     *            long
     * @return String
     */
    public static String getTimeFormat(long lSecond) {
        String szTime = new String();
 
        if (lSecond <= 0) {
            szTime = "00" + ":" + "00" + ":" + "00";
        } else {
            long hour = lSecond / 3600;
            long minute = (lSecond - hour * 3600) / 60;
            long second = (lSecond - hour * 3600 - minute * 60);
 
            if (hour <= 0) {
                szTime = "00";
            } else if (hour < 10) {
                szTime = "0" + String.valueOf(hour);
            } else {
                szTime = String.valueOf(hour);
            }
            szTime = szTime + ":";
 
            if (minute <= 0) {
                szTime = szTime + "00";
            } else if (minute < 10) {
                szTime = szTime + "0" + String.valueOf(minute);
            } else {
                szTime = szTime + String.valueOf(minute);
            }
            szTime = szTime + ":";
 
            if (second <= 0) {
                szTime = szTime + "00";
            } else if (second < 10) {
                szTime = szTime + "0" + String.valueOf(second);
            } else {
                szTime = szTime + String.valueOf(second);
            }
        }
 
        return szTime;
    }
 
    public static String getFormattedDateUtil(Date dtDate, String strFormatTo) {
        if (dtDate == null) {
            return "";
        }
        strFormatTo = strFormatTo.replace('/', '-');
        try {
            SimpleDateFormat formatter = new SimpleDateFormat(strFormatTo);
            return formatter.format(dtDate);
        } catch (Exception e) {
            // Common.printLog("转换日期字符串格式时出错;" + e.getMessage());
            return "";
        }
    }
 
    /**
     * 得出两个日期之间的间隔天数
     *
     * @param strFromDate
     *            格式为yyyy-MM-dd
     * @param strToDate
     *            格式为yyyy-MM-dd
     * @return int
     */
    public static long getBetweenDays(String strFromDate, String strToDate) {
        long m_intervalday = 0;// 初始化时间间隔的值为0
        // 使用的时间格式为yyyy-MM-dd
        SimpleDateFormat m_simpledateformat = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date fromDate = m_simpledateformat.parse(strFromDate);
            Date toDate = m_simpledateformat.parse(strToDate);
            m_intervalday = toDate.getTime() - fromDate.getTime();// 计算所得为微秒数
            m_intervalday = m_intervalday / 1000 / 60 / 60 / 24;// 计算所得的天数
 
            return m_intervalday + 1;
        } catch (Exception e) {
            return Integer.MIN_VALUE;
        }
    }
 
    // 原DateUtil方法
    private static DateUtil instance = null;
 
    private static final Locale local = Locale.ENGLISH;
 
    public static synchronized DateUtil getInstance() {
        if (instance == null) {
            instance = new DateUtil();
        }
        return instance;
    }
 
    public static final long millisInDay = 86400000;
 
    // some static date formats
    private static SimpleDateFormat[] mDateFormats = loadDateFormats();
 
    private static final SimpleDateFormat mFormat8chars = new SimpleDateFormat("yyyyMMdd");
 
    private static final SimpleDateFormat mFormatIso8601Day = new SimpleDateFormat("yyyy-MM-dd");
 
    private static final SimpleDateFormat mFormatIso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
 
    // http://www.w3.org/Protocols/rfc822/Overview.html#z28
    private static final SimpleDateFormat mFormatRfc822 = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z");
 
    private static final SimpleDateFormat mFormatTradeEasy = new SimpleDateFormat("MM/dd/yyyy HH:mm");
 
    private static final SimpleDateFormat mFormatTradeEasyMMddyyyy = new SimpleDateFormat("MM/dd/yyyy");
 
    // add by huyanzhi
    private static final SimpleDateFormat mFormatTradeEasyProduct = new SimpleDateFormat("dd/MM/yyyy");
    // end
 
    private static final SimpleDateFormat mFormatExpire = new SimpleDateFormat("MMMM dd, yyyy", local);
 
    private static SimpleDateFormat[] loadDateFormats() {
        SimpleDateFormat[] temp = {
                // new SimpleDateFormat("MM/dd/yyyy hh:mm:ss.SSS a"),
                new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy"),
                // standard Date.toString() results
                new SimpleDateFormat("M/d/yy hh:mm:ss"), new SimpleDateFormat("M/d/yyyy hh:mm:ss"),
                new SimpleDateFormat("M/d/yy hh:mm a"), new SimpleDateFormat("M/d/yyyy hh:mm a"),
                new SimpleDateFormat("M/d/yy HH:mm"), new SimpleDateFormat("M/d/yyyy HH:mm"),
                new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"), new SimpleDateFormat("yy-MM-dd HH:mm:ss.SSS"),
                new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"),
                // standard Timestamp.toString() results
                new SimpleDateFormat("M-d-yy HH:mm"), new SimpleDateFormat("M-d-yyyy HH:mm"),
                new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS"), new SimpleDateFormat("M/d/yy"),
                new SimpleDateFormat("M/d/yyyy"), new SimpleDateFormat("M-d-yy"), new SimpleDateFormat("M-d-yyyy"),
                new SimpleDateFormat("MMMM d, yyyyy"), new SimpleDateFormat("MMM d, yyyyy") };
 
        return temp;
    }
 
    // -----------------------------------------------------------------------
    /**
     * Gets the array of SimpleDateFormats that DateUtil knows about.
     **/
    private static SimpleDateFormat[] getFormats() {
        return mDateFormats;
    }
 
    // -----------------------------------------------------------------------
    /**
     * Returns a Date set to the last possible millisecond of the day, just
     * before midnight. If a null day is passed in, a new Date is created.
     * midnight (00m 00h 00s)
     */
    public static Date getEndOfDay(Date day) {
        return getEndOfDay(day, Calendar.getInstance());
    }
 
    public static Date getEndOfDay(Date day, Calendar cal) {
        if (day == null)
            day = new Date();
        cal.setTime(day);
        cal.set(Calendar.HOUR_OF_DAY, cal.getMaximum(Calendar.HOUR_OF_DAY));
        cal.set(Calendar.MINUTE, cal.getMaximum(Calendar.MINUTE));
        cal.set(Calendar.SECOND, cal.getMaximum(Calendar.SECOND));
        cal.set(Calendar.MILLISECOND, cal.getMaximum(Calendar.MILLISECOND));
        return cal.getTime();
    }
 
    // -----------------------------------------------------------------------
    /**
     * Returns a Date set to the first possible millisecond of the day, just
     * after midnight. If a null day is passed in, a new Date is created.
     * midnight (00m 00h 00s)
     */
    public static Date getStartOfDay(Date day) {
        return getStartOfDay(day, Calendar.getInstance());
    }
 
    /**
     * Returns a Date set to the first possible millisecond of the day, just
     * after midnight. If a null day is passed in, a new Date is created.
     * midnight (00m 00h 00s)
     */
    public static Date getStartOfDay(Date day, Calendar cal) {
        if (day == null)
            day = new Date();
        cal.setTime(day);
        cal.set(Calendar.HOUR_OF_DAY, cal.getMinimum(Calendar.HOUR_OF_DAY));
        cal.set(Calendar.MINUTE, cal.getMinimum(Calendar.MINUTE));
        cal.set(Calendar.SECOND, cal.getMinimum(Calendar.SECOND));
        cal.set(Calendar.MILLISECOND, cal.getMinimum(Calendar.MILLISECOND));
        return cal.getTime();
    }
 
    /**
     * Returns a Date set just to Noon, to the closest possible millisecond of
     * the day. If a null day is passed in, a new Date is created. nnoon (00m
     * 12h 00s)
     */
    public static Date getNoonOfDay(Date day, Calendar cal) {
        if (day == null)
        {
            day = new Date();
        }
        cal.setTime(day);
        cal.set(Calendar.HOUR_OF_DAY, 12);
        cal.set(Calendar.MINUTE, cal.getMinimum(Calendar.MINUTE));
        cal.set(Calendar.SECOND, cal.getMinimum(Calendar.SECOND));
        cal.set(Calendar.MILLISECOND, cal.getMinimum(Calendar.MILLISECOND));
        return cal.getTime();
    }
 
    /**
     * 根据传入的日期字符串转换成相应的日期对象,如果字符串为空或不符合日期格 式,则返回当前时间。
     *
     * @param strDate
     *            String 日期字符串
     * @return java.util.Date 日期对象
     */
    public static Date getDateFromString(String strDate) {
        if (StringUtils.isEmpty(strDate)) {
            return new Date(System.currentTimeMillis());
        }
        try {
            return sdfLongTimePlus.parse(strDate);
        } catch (Exception ex) {
            return new Timestamp(System.currentTimeMillis());
        }
    }
    public static Date getDateFromString2(String strDate) {
        if (StringUtils.isEmpty(strDate)) {
            return new Date(System.currentTimeMillis());
        }
        try {
            return sdfLongTimePlus.parse(strDate);
        } catch (Exception ex) {
           return  null;
        }
    }
 
    // -----------------------------------------------------------------------
    public static Date parseFromFormats(String aValue) {
        if (StringUtils.isEmpty(aValue))
            return null;
 
        // get DateUtil's formats
        SimpleDateFormat formats[] = DateUtil.getFormats();
        if (formats == null)
            return null;
 
        // iterate over the array and parse
        Date myDate = null;
        for (int i = 0; i < formats.length; i++) {
            try {
                myDate = DateUtil.parse(aValue, formats[i]);
                // if (myDate instanceof Date)
                return myDate;
            } catch (Exception e) {
                // do nothing because we want to try the next
                // format if current one fails
            }
        }
        // haven't returned so couldn't parse
        return null;
    }
 
    // -----------------------------------------------------------------------
    public static Timestamp parseTimestampFromFormats(String aValue) {
        if (StringUtils.isEmpty(aValue))
        {
            return null;
        }
 
        // call the regular Date formatter
        Date myDate = DateUtil.parseFromFormats(aValue);
        if (myDate != null)
        {
            return new Timestamp(myDate.getTime());
        }
        return null;
    }
 
    // -----------------------------------------------------------------------
    /**
     * Returns a java.sql.Timestamp equal to the current time
     **/
    public static Timestamp now() {
        return new Timestamp(System.currentTimeMillis());
    }
 
    // -----------------------------------------------------------------------
    /**
     * Returns a string the represents the passed-in date parsed according to
     * the passed-in format. Returns an empty string if the date or the format
     * is null.
     **/
    public static String format(Date aDate, SimpleDateFormat aFormat) {
        if (aDate == null || aFormat == null) {
            return "";
        }
        synchronized (aFormat) {
            return aFormat.format(aDate);
        }
    }
 
    // -----------------------------------------------------------------------
    /**
     * Tries to take the passed-in String and format it as a date string in the
     * the passed-in format.
     **/
    public static String formatDateString(String aString, SimpleDateFormat aFormat) {
        if (StringUtils.isEmpty(aString) || aFormat == null)
            return "";
        try {
            Timestamp aDate = parseTimestampFromFormats(aString);
            if (aDate != null) {
                return DateUtil.format(aDate, aFormat);
            }
        } catch (Exception e) {
            // Could not parse aString.
        }
        return "";
    }
 
    // -----------------------------------------------------------------------
    /**
     * Returns a Date using the passed-in string and format. Returns null if the
     * string is null or empty or if the format is null. The string must match
     * the format.
     **/
    public static Date parse(String aValue, SimpleDateFormat aFormat) throws ParseException {
        if (StringUtils.isEmpty(aValue) || aFormat == null) {
            return null;
        }
 
        return aFormat.parse(aValue);
    }
 
    // -----------------------------------------------------------------------
    /**
     * Returns true if endDate is after startDate or if startDate equals endDate
     * or if they are the same date. Returns false if either value is null.
     **/
    public static boolean isValidDateRange(Date startDate, Date endDate) {
        return isValidDateRange(startDate, endDate, true);
    }
 
    // -----------------------------------------------------------------------
    /**
     * Returns true if endDate is after startDate or if startDate equals
     * endDate. Returns false if either value is null. If equalOK, returns true
     * if the dates are equal.
     **/
    public static boolean isValidDateRange(Date startDate, Date endDate, boolean equalOK) {
        // false if either value is null
        if (startDate == null || endDate == null) {
            return false;
        }
 
        if (equalOK) {
            // true if they are equal
            if (startDate.equals(endDate)) {
                return true;
            }
        }
 
        // true if endDate after startDate
        if (endDate.after(startDate)) {
            return true;
        }
 
        return false;
    }
 
    // -----------------------------------------------------------------------
    // returns full timestamp format
    public static SimpleDateFormat defaultTimestampFormat() {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    }
 
    // -----------------------------------------------------------------------
    // convenience method returns minimal date format
    public static SimpleDateFormat get8charDateFormat() {
        return DateUtil.mFormat8chars;
    }
 
    // -----------------------------------------------------------------------
    // convenience method returns minimal date format
    public static SimpleDateFormat defaultDateFormat() {
        return DateUtil.friendlyDateFormat(true);
    }
 
    // -----------------------------------------------------------------------
    // convenience method
    public static String defaultTimestamp(Date date) {
        return DateUtil.format(date, DateUtil.defaultTimestampFormat());
    }
 
    // -----------------------------------------------------------------------
    // convenience method
    public static String defaultDate(Date date) {
        return DateUtil.format(date, DateUtil.defaultDateFormat());
    }
 
    // -----------------------------------------------------------------------
    // convenience method returns long friendly timestamp format
    public static SimpleDateFormat friendlyTimestampFormat() {
        return new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
    }
 
    // -----------------------------------------------------------------------
    // convenience method returns long friendly formatted timestamp
    public static String friendlyTimestamp(Date date) {
        return DateUtil.format(date, DateUtil.friendlyTimestampFormat());
    }
 
    // -----------------------------------------------------------------------
    // convenience method returns long friendly formatted timestamp
    public static String format8chars(Date date) {
        return DateUtil.format(date, mFormat8chars);
    }
 
    // -----------------------------------------------------------------------
    // convenience method returns long friendly formatted timestamp
    public static String formatIso8601Day(Date date) {
        return DateUtil.format(date, mFormatIso8601Day);
    }
 
    public static String formatIso8601Day(Timestamp timestamp) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(timestamp.getTime());
        return DateUtil.format(calendar.getTime(), mFormatIso8601Day);
    }
 
    public static String formatTradeEasy(Date date) {
        return DateUtil.format(date, mFormatTradeEasy);
    }
 
    // add by huyanzhi
    public static String formatTradeEasyProduct(Date date) {
        return DateUtil.format(date, mFormatTradeEasyProduct);
    }
 
    //
 
    public static String formatFormatTradeEasyMMddyyyy(Date date) {
        return DateUtil.format(date, mFormatTradeEasyMMddyyyy);
    }
 
    public static String formatTradeEasy(Timestamp timestamp) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(timestamp.getTime());
        return DateUtil.format(calendar.getTime(), mFormatTradeEasy);
    }
 
    // -----------------------------------------------------------------------
    public static String formatRfc822(Date date) {
        return DateUtil.format(date, mFormatRfc822);
    }
 
    public static String formatExpire(Date date) {
        return DateUtil.format(date, mFormatExpire);
    }
 
    // -----------------------------------------------------------------------
    // This is a hack, but it seems to work
    public static String formatIso8601(Date date) {
        if (date == null)
            return "";
 
        // Add a colon 2 chars before the end of the string
        // to make it a valid ISO-8601 date.
 
        String str = DateUtil.format(date, mFormatIso8601);
        StringBuffer sb = new StringBuffer();
        sb.append(str.substring(0, str.length() - 2));
        sb.append(":");
        sb.append(str.substring(str.length() - 2));
        return sb.toString();
    }
 
    // -----------------------------------------------------------------------
    // convenience method returns minimal date format
    public static SimpleDateFormat minimalDateFormat() {
        return DateUtil.friendlyDateFormat(true);
    }
 
    // -----------------------------------------------------------------------
    // convenience method using minimal date format
    public static String minimalDate(Date date) {
        return DateUtil.format(date, DateUtil.minimalDateFormat());
    }
 
    // -----------------------------------------------------------------------
    // convenience method that returns friendly data format
    // using full month, day, year digits.
    public static SimpleDateFormat fullDateFormat() {
        return DateUtil.friendlyDateFormat(false);
    }
 
    // -----------------------------------------------------------------------
    public static String fullDate(Date date) {
        return DateUtil.format(date, DateUtil.fullDateFormat());
    }
 
    // -----------------------------------------------------------------------
    /**
     * Returns a "friendly" date format.
     *
     * @param minimalFormat
     *            Should the date format allow single digits.
     **/
    public static SimpleDateFormat friendlyDateFormat(boolean minimalFormat) {
        if (minimalFormat) {
            return new SimpleDateFormat("d.M.yy");
        }
 
        return new SimpleDateFormat("dd.MM.yyyy");
    }
 
    // -----------------------------------------------------------------------
    /**
     * Format the date using the "friendly" date format.
     */
    public static String friendlyDate(Date date, boolean minimalFormat) {
        return DateUtil.format(date, DateUtil.friendlyDateFormat(minimalFormat));
    }
 
    // -----------------------------------------------------------------------
    // convenience method
    public static String friendlyDate(Date date) {
        return DateUtil.format(date, DateUtil.friendlyDateFormat(true));
    }
 
    public static Date parseFormatIso8601Date(String date) throws Exception {
        Date returnDate = null;
        try {
            returnDate = mFormatIso8601Day.parse(date);
        } catch (Exception e) {
            throw e;
        }
        return returnDate;
    }
 
    // add by huyanzhi
    @SuppressWarnings("deprecation")
    public static String addDate(String date, String type, int into) throws Exception {
        String Sdate = "";
        try {
            GregorianCalendar grc = new GregorianCalendar();
            grc.setTime(new Date(date));
            if (type.equals("D")) {
                grc.add(GregorianCalendar.DATE, into);
            } else if (type.equals("M")) {
                grc.add(GregorianCalendar.MONTH, into);
            } else if (type.equals("Y")) {
                grc.add(GregorianCalendar.YEAR, into);
            }
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
            Sdate = new String(formatter.format(grc.getTime()));
        } catch (Exception e) {
            throw e;
        }
        return Sdate;
    }
 
    @SuppressWarnings("deprecation")
    public static String addDate(String date, String into) throws Exception {
        String Sdate = "";
        try {
            date = date.replaceAll("-", "/");
            date = date.substring(0, date.length() - 2);
            GregorianCalendar grc = new GregorianCalendar();
            grc.setTime(new Date(date));
            grc.add(GregorianCalendar.DATE, Integer.parseInt(into));
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
            Sdate = new String(formatter.format(grc.getTime()));
        } catch (Exception e) {
            throw e;
        }
        return Sdate;
    }
 
    public static String formatDate(Date date, String pattern) {
        if (date == null) {
            return null;
        }
        if (pattern == null || pattern.equals("") || pattern.equals("null")) {
            pattern = "yyyy-MM-dd";
        }
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        return sdf.format(date);
    }
 
    //
 
    @SuppressWarnings("deprecation")
    public static String addValidateDate(String date, String into) throws Exception {
        String Sdate = "";
        try {
            date = date.replaceAll("-", "/");
            date = date.substring(0, date.length() - 2);
            GregorianCalendar grc = new GregorianCalendar();
            grc.setTime(new Date(date));
            grc.add(GregorianCalendar.DATE, Integer.parseInt(into));
            Sdate = new String(mFormatExpire.format(grc.getTime()));
        } catch (Exception e) {
            throw e;
        }
        return Sdate;
    }
 
    public static String addDayToStringDate(String formate, String strDate, String days) {
        String stringDate = null;
        try {
            Date date = fromStringToDate(formate, strDate);
            long now = date.getTime() + (long) Integer.parseInt(days) * DAY_IN_MILLISECOND;
 
            stringDate = getFomartDate(new Date(now), formate);
 
        } catch (ParseException e) {
 
            e.printStackTrace();
        }
 
        return stringDate;
    }
 
    public static Date addDayToStringDate2(String formate, String strDate, String days) {
        Date date = null;
        try {
            date = fromStringToDate(formate, strDate);
            long now = date.getTime() + (long) Integer.parseInt(days) * DAY_IN_MILLISECOND;
 
            date = new Date(now);
 
        } catch (ParseException e) {
 
            e.printStackTrace();
        }
 
        return date;
    }
 
    public static Date dateDayAdd(Date date, int days) {
        long now = date.getTime() + (long) days * DAY_IN_MILLISECOND;
        return new Date(now);
    }
 
    /**
     *
     * 字符串形式转化为Date类型 String类型按照format格式转为Date类型
     **/
    public static Date fromStringToDate(String format, String dateTime) throws ParseException {
        Date date = null;
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        date = sdf.parse(dateTime);
        return date;
    }
 
    /**
     *
     * 字符串形式转化为Date类型 String类型按照format格式转为Date类型
     **/
    public static Date fromStringToDate(Date date) throws ParseException {
        return sdfLongTimePlus.parse(sdfLongTimePlus.format(date));
    }
 
    public static void main(String[] args) {
        try {
            System.out.println((int)(3.222));
 
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
 
    /**
     *
     * <br>
     * <b>功能:</b>返回时分秒:HHmmss<br>
     * <b>作者:</b>www.doumee.com<br>
     * <b>日期:</b> Aug 26, 2013 <br>
     *
     * @param date
     * @return
     */
    public static Integer getTimeFormatIntger(Date date) {
        if (date == null) {
            return 0;
        }
        String strTemp = DateUtil.getFomartDate(date, "yyyyMMddHHmmss");
        String nowTime = strTemp.substring(8, 14);
        return Integer.valueOf(nowTime);
    }
 
    public static String getNowDayStr(Date date) {
        if (date == null) {
            return "";
        }
 
        Calendar c = Calendar.getInstance();
        int i = c.get(Calendar.DAY_OF_WEEK);
        System.out.println(i);
        // String strTemp = DateUtil.getFomartDate(date, "yyyyMMddHHmmss");
        // String nowTime = strTemp.substring(8,14);
        return "";
    }
 
    /**
     * @param format
     *            日期格式
     * @return String
     * @author zhangyong
     * @return String
     */
    public static String toDayToStr(String format) {
        try {
            Date now = new Date();
            return DateToStr(now, format) + " " + getWeekOfDate(now);
        } catch (Exception e) {
            System.out.println("Date 转 String 类型失败: " + e);
            return null;
        }
    }
 
    /**
     * @param date
     * @param format
     *            日期格式
     * @return String
     * @author zhangyong
     * @return String
     */
    public static String DateToStr(Date date, String format) {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat(format);
            return sdf.format(date);
        } catch (Exception e) {
            System.out.println("Date 转 String 类型失败: " + e);
            return null;
        }
    }
 
    /**
     * @author zhangyong
     * @return DATE 型加具体的天数
     *
     * @param date
     *            date, int days
     */
    public static Date dateAddDays(Date date, int days) {
        long now = date.getTime() + (long) days * DAY_IN_MILLISECOND;
        return new Date(now);
    }
 
    /**
     * @return 将DATE 转换成字符性日期格式
     * @author zhangyong
     * @param date
     *            date,String fFormatStr eg:yyyy-MM-dd HH:mm:ss
     */
    public static String dateTypeToString(Date date, String fFormatStr) {
        // yyyy-MM-dd HH:mm:ss
        SimpleDateFormat dateformat = new SimpleDateFormat(fFormatStr);
        String strDate = dateformat.format(date);
        return strDate;
    }
 
    /**
     * @param fFormatStr
     *            -MM-dd
     * @author zhangyong
     * @获取当前的系统时间,并按照固定的格式初始话
     */
    public static String getStringOfNowDate(String fFormatStr) {
        String nowDateString = dateTypeToString(new Date(), fFormatStr);
        return nowDateString;
    }
 
    /**
     * @ author zhangyong @ 获取当月的第一天,2009-05-01
     */
    public static String getStringOfFirstDayInMonth() {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
        String temp = sdf.format(date);
        String firstDayInMoth = "";
        firstDayInMoth = temp + "-01";
 
        return firstDayInMoth;
 
    }
 
    /**
     * 获取当前日期是星期几<br>
     *
     * @param dt
     * @return 当前日期是星期几
     */
    public static String getWeekOfDate(Date dt) {
        String[] weekDays = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
        Calendar cal = Calendar.getInstance();
        cal.setTime(dt);
 
        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (w < 0)
        {
            w = 0;
        }
 
        return weekDays[w];
    }
 
    /**
     * 获取星期数
     *
     * @param dt
     * @return
     */
    public static int getWeekNumOfDate(Date dt) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(dt);
 
        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (w <= 0)
            w = 7;
 
        return w;
    }
 
    public static Long twoDaysBetween(Date beginDate, Date endDate) throws ParseException {
        long minute = (endDate.getTime() - beginDate.getTime()) / (60 * 1000);
        return minute;
    }
 
    /**
     * 取两月以前的1好
     *
     * @return
     */
    public static Date initDateByTwoMonthAgo() {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.add(Calendar.MONTH, -2);// 月份减1
        return calendar.getTime();
    }
 
    /**
     * 某时间增加指定天数后的日期
     *
     * @return
     */
    public static Date addDaysToDate(Date date, int days) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.DATE, days);//
        return calendar.getTime();
    }
 
    public static String afterDateToStr(Integer days){
        Date date = new Date();
        Long l = date.getTime()+1000*60*60*24*days;
        date.setTime(l);
        return DateToStr(date, "yyyyMMdd");
    }
 
    public static String beforeDateToStr(Integer days){
        Date date = new Date();
        Long l = date.getTime()-1000*60*60*24*days;
        date.setTime(l);
        return DateToStr(date, "yyyyMMdd");
    }
 
    public static String getLongDate(Date date) {
        return DateToString(date, "yyyyMMddHHmmss");
    }
 
    public static String DateToString(Date date, String dateStyle) {
        String dateString = null;
        if (dateStyle != null) {
            dateString = DateToStringDtl(date, dateStyle);
        }
        return dateString;
    }
 
    public static String DateToStringDtl(Date date, String parttern) {
        String dateString = null;
        if (date != null) {
            try {
                dateString = getDateFormat(parttern).format(date);
            } catch (Exception e) {
            }
        }
        return dateString;
    }
 
    /**
     * 获取SimpleDateFormat
     *
     * @param parttern 日期格式
     * @return SimpleDateFormat对象
     * @throws RuntimeException 异常:非法日期格式
     */
    private static SimpleDateFormat getDateFormat(String parttern) throws RuntimeException {
        return new SimpleDateFormat(parttern);
    }
 
 
    /**
     * X 分钟后时间
     * @param minutes
     * @return
     */
    public static Date afterMinutesDate(Integer minutes){
        Date date = new Date();
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.add(Calendar.MINUTE,minutes);
        return cal.getTime();
    }
 
 
    /**
     * 2个日期之间相差分钟数
     * @param begin
     * @param end
     * @return
     */
    public static Integer betweenMin(Date begin, Date end) {
        if(begin ==null ){
            return  0;
        }
        long createTime =begin.getTime();//获取创建时间的时间戳
        long currentTime =Objects.isNull(end)?System.currentTimeMillis():end.getTime();//获取当前时间的时间戳
        long diff=(currentTime-createTime)/1000/60;//获取两个时间相差的分钟
        return (int)diff + 1 ;
    }
 
 
    /**
     * 计算耗时
     * @param start
     * @param end
     * @return
     */
    public static String calculation(Date start,Date end){
        Long millisecond = end.getTime() - start.getTime();
        long day = millisecond / (24 * 60 * 60 * 1000);
        long hour = (millisecond / (60 * 60 * 1000));
        long min = ((millisecond / (60 * 1000)) - day * 24 * 60 - hour * 60);
        long s = (millisecond / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
        StringBuffer consuming = new StringBuffer();
        consuming.append(hour==0?"":hour+":");
        consuming.append(StringUtils.leftPad(Long.toString(min),2,"0")+":");
        consuming.append(StringUtils.leftPad(Long.toString(s),2,"0"));
        return consuming.toString();
    }
 
}