churf
2023-09-11 0eb4d8c770bb6d2df8ffdbf78e9567481c37a593
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
package me.zhengjie.modules.quartz.utils;
 
import io.swagger.models.auth.In;
import me.zhengjie.utils.StringUtils;
 
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
 
public class DateTimeUtil {
 
    public static final String DIVIDE_LINE = "-";
    public static final String DIVIDE_COLON = ":";
 
    public static final long SECOND = 1000;
    public static final long MINUTE = 60 * SECOND;
    public static final long HOUR = 60 * MINUTE;
    public static final long DAY = 24 * HOUR;
    public static final long WEEK = 7 * DAY;
    public static final String YEARFORMAT = "yyyy";
    public static final String MONTHFORMAT = "yyyy-MM";
    public static final String SHORTFORMAT = "yyyy-MM-dd";
    public static final String SHORTFORMATNOSPIT = "yyyyMMdd";
    public static final String LONGFORMATNOSPIT = "yyyyMMddHHmmss";
    public static final String LONGFORMAT = "yyyy-MM-dd HH:mm:ss";
    public static final String SUPERLONGFORMAT = "yyyy-MM-dd HH:mm:ss sss";
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
    public static final int FIELD_YEAR = Calendar.YEAR;
    public static final int FIELD_MONTH = Calendar.MONTH;
    public static final int FIELD_DATE = Calendar.DATE;
 
    /**
     * 时间戳格式化 yyyy-MM-dd HH:mm:ss
     */
    public static String getTimestampString(Date date) {
        return sdf.format(date).toString();
    }
 
    /**
     * 系统当前时间戳
     */
    public static Timestamp getTimestamp(){
        SimpleDateFormat myFormat = new SimpleDateFormat(LONGFORMAT);
        long stamp = System.currentTimeMillis();
        String timestamp = myFormat.format(stamp);
        return Timestamp.valueOf(timestamp);
    }
 
 
    /**
     * 日期转时间戳
     */
    public static Timestamp getTimestamp(Date date) {
        return Timestamp.valueOf(getTimestampString(date));
    }
 
    /**
     * 字符串转时间戳
     */
    public static Timestamp getTimestamp(String timestamp) {
        if(StringUtils.isEmpty(timestamp)){
            return null;
        }
        return Timestamp.valueOf(timestamp);
    }
 
    /**
     * 时间格式化 yyyy-MM-dd
     */
    public static String getDate() {
        SimpleDateFormat myFormat = new SimpleDateFormat(SHORTFORMAT);
        return myFormat.format(System.currentTimeMillis());
    }
 
    /**
     * 时间格式化 yyyy-MM-dd
     */
    public static String getDate(Date date) {
        return getDate(date, SHORTFORMAT);
    }
 
    /**
     * 时间格式化 yyyy-MM-dd
     */
    public static String getDate(Date date, String format) {
        String result = null;
        try {
            SimpleDateFormat myFormat = new SimpleDateFormat(format);
            result = myFormat.format(date);
        } catch (Exception e) {
            return null;
        }
        return result;
    }
 
    /**
     * 时间格式化 yyyy-MM-dd HH:mm:ss
     * */
    public static String getDateTime() {
        return getDateTime(new Date());
    }
 
    /**
     * 时间格式化 yyyy-MM-dd HH:mm:ss
     * */
    public static String getDateTime(Date date) {
        SimpleDateFormat d = new SimpleDateFormat(LONGFORMAT);
        return d.format(date);
    }
 
    /**
     * 时间格式化 yyyy-MM-dd
     * */
    public static String getShortDate(Date date){
        if(date==null)
            date = new Date();
        return getDate(date, SHORTFORMAT);
    }
 
    /**
     * 时间格式化 yyyy-MM-dd HH:mm:ss
     * */
    public static String getLongDate(Date date){
        if(date==null)
            date = new Date();
        return getDateTime(date);
    }
 
    /**
     * 时间格式化 yyyy-MM-dd HH:mm:ss
     * */
    public static String getTimestampStr(){
        SimpleDateFormat myFormat = new SimpleDateFormat(LONGFORMAT);
        return myFormat.format(System.currentTimeMillis());
    }
 
    /**
     * 时间格式化 yyyyMMddHHmmss
     * */
    public static String getLongTime(){
        SimpleDateFormat myFormat = new SimpleDateFormat(LONGFORMATNOSPIT);
        return myFormat.format(System.currentTimeMillis());
    }
 
    /**
     * 时间格式化 yyyyMMddHHmmss
     * */
    public static String getLongTime(long ts){
        SimpleDateFormat myFormat = new SimpleDateFormat(LONGFORMATNOSPIT);
        return myFormat.format(ts);
    }
 
    /**
     * 时间戳TS
     */
    public static String getTS(){
        long ts = System.currentTimeMillis();
        return Long.toString(ts);
    }
 
    /**
     * N年后
     * */
    public static Date addYear(Date date, int amount) {
        return add(date, Calendar.YEAR, amount);
    }
 
    /**
     * N个月后
     * */
    public static Date addMonth(Date date, int amount) {
        return add(date, Calendar.MONTH, amount);
    }
 
    /**
     * 得到某一天的该星期的第一日 00:00:00
     *
     * @param date
     * @param firstDayOfWeek
     *            一个星期的第一天为星期几
     *
     * @return
     */
    public static Date getFirstDayOfWeek(Date date, int firstDayOfWeek) {
        Calendar cal = Calendar.getInstance();
        if (date != null)
            cal.setTime(date);
        cal.setFirstDayOfWeek(firstDayOfWeek);//设置一星期的第一天是哪一天
        cal.set(Calendar.DAY_OF_WEEK, firstDayOfWeek);//指示一个星期中的某天
        cal.set(Calendar.HOUR_OF_DAY, 0);//指示一天中的小时。HOUR_OF_DAY 用于 24 小时制时钟。例如,在 10:04:15.250 PM 这一时刻,HOUR_OF_DAY 为 22。
        cal.set(Calendar.MINUTE, 0);//指示一小时中的分钟。例如,在 10:04:15.250 PM 这一时刻,MINUTE 为 4。
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return cal.getTime();
    }
 
    /**
     * N天后
     * */
    public static Date addDay(Date date, int amount) {
        return add(date, Calendar.DATE, amount);
    }
 
    /**
     * N(年、月、天)后
     * */
    public static Date add(Date date, int field, int amount) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(field, amount);
        return calendar.getTime();
    }
 
    /**
     * N(年、月、天)后
     * */
    public static Date add(String datestr, int field, int amount) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(formatDate(datestr));
        calendar.add(field, amount);
        return calendar.getTime();
    }
 
    /**
     * N(年、月、天)后(字符串形式)
     * */
    public static String add(String datestr, int field, int amount, String format) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(formatDate(datestr,format));
        calendar.add(field, amount);
        return getDate(calendar.getTime(), format);
    }
 
    /***
     * 获取当前时间,不含日期
     * @return
     */
    public static String getCurrentTime(){
        SimpleDateFormat sdf = new SimpleDateFormat("kk:mm:ss");
        String time = sdf.format(Calendar.getInstance().getTime());
        return time;
    }
 
    /**
     * 将字符串转为为日期
     */
    public static Date formatDate(String datestr) {
        if(19==datestr.length()){
            return formatDate(datestr, LONGFORMAT);
        }else{
            return formatDate(datestr, SHORTFORMAT);
        }
    }
 
    /**
     * 将字符串转为为日期
     */
    public static Date formatDate(String datestr, String format) {
        try {
            if(StringUtils.isEmpty(datestr)){
                return null;
            }
            SimpleDateFormat myFormat = new SimpleDateFormat(format);
            Date date = myFormat.parse(datestr);
            return date;
        } catch (Exception e) {
            return null;
        }
    }
 
    /***
     * 月份的开始结束日期
     * @param year
     * @param month
     * @param keys
     * @return
     */
    public static Map<String, String> getMonthStartDateAndEndDate(int year, int month,
                                                                  String... keys) {
        SimpleDateFormat d = new SimpleDateFormat(LONGFORMAT);
        Map<String, String> date = new HashMap<String, String>();
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, year);
        calendar.set(Calendar.MONTH, month - 1);
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        date.put(keys[0], d.format(calendar.getTime()));
        calendar.add(Calendar.MONTH, 1);
        calendar.add(Calendar.DAY_OF_MONTH, -1);
        date.put(keys[1], d.format(calendar.getTime()));
        return date;
    }
 
    /**
     * 时间格式化
     */
    public static String getTimeString(String time) {
        String[] ti = time.split(":");
        if (ti[1].length() == 1) {
            time = ti[0] + "0" + ti[1];
        } else {
            time = ti[0] + ti[1];
        }
        return time;
    }
 
    /**
     * <br>描 述: 获取计费模式的年月  2017-06-26 至 2017-07-25 为 2017年07月 以此类推
     * <br>作 者: shizhenwei
     * <br>历 史: (版本) 作者 时间 注释
     * @return
     */
    public static String getSicdtYearMonth(String datestr){
        String[] fileds = datestr.split(DIVIDE_LINE);
        if(Integer.valueOf(fileds[2])>25){
            Date date = add(datestr, FIELD_MONTH, 1);
            return getDate(date, MONTHFORMAT);
        }
        return datestr.substring(0, 7);
    }
 
    public static String getSicdtYearMonth(){
        return getSicdtYearMonth(getDate());
    }
 
    @SuppressWarnings("deprecation")
    public static String timeString() {
        Date date = new Date();
        return getTimeString(date.getHours() + ":" + date.getMinutes());
    }
 
 
    /**
     * 月-天数
     * */
    public static int getDayNum(int year, int month) {
        if (month == 2) {
            return year % 400 != 0 && (year % 4 != 0 || year % 100 == 0) ? 28
                    : 29;
        }
        String SmallMonth = ",4,6,9,11,";
        return SmallMonth.indexOf(String.valueOf(String
                .valueOf((new StringBuffer(",")).append(String.valueOf(month))
                        .append(",")))) < 0 ? 31 : 30;
    }
    /***
     * 两个日期之间的天数
     * @param date1
     * @param date2
     * @return
     */
    public static int DateDiff(Date date1, Date date2) {
        int i = (int) ((date1.getTime() - date2.getTime()) / 3600 / 24 / 1000);
        return i;
    }
    /**
     * 日期拆分,取年或月或日    Y-年  M-月  D-日
     * @param strDate
     * @param style
     * @return
     */
    public static int getYearMonthDate(String strDate, String style) {
        int year;
        int month;
        int day;
        int firstDash;
        int secondDash;
        if (strDate == null) {
            return 0;
        }
        firstDash = strDate.indexOf('-');
        secondDash = strDate.indexOf('-', firstDash + 1);
        if ((firstDash > 0) & (secondDash > 0)
                & (secondDash < strDate.length() - 1)) {
            year = Integer.parseInt(strDate.substring(0, firstDash));
            month = Integer.parseInt(strDate.substring(firstDash + 1,
                    secondDash));
            day = Integer.parseInt(strDate.substring(secondDash + 1));
        } else {
            return 0;
        }
        if (style.equalsIgnoreCase("Y")) {
            return year;
        } else if (style.equalsIgnoreCase("M")) {
            return month;
        } else if (style.equalsIgnoreCase("D")) {
            return day;
        } else {
            return 0;
        }
    }
 
    /***
     * 是否是年份的第一天
     * @param date
     * @return
     */
    public static boolean isYearFirstDay(java.sql.Date date) {
        boolean i = false;
        if ((DateTimeUtil.getYearMonthDate(date.toString(), "M") == 1)
                && (DateTimeUtil.getYearMonthDate(date.toString(), "D") == 1)) {
            i = true;
        }
        return i;
    }
    /**
     * 是否是半年的第一天
     * @param date
     * @return
     */
    public static boolean isHalfYearFirstDay(java.sql.Date date) {
        boolean i = false;
        if (((DateTimeUtil.getYearMonthDate(date.toString(), "M") == 1) && (DateTimeUtil
                .getYearMonthDate(date.toString(), "D") == 1))
                || ((DateTimeUtil.getYearMonthDate(date.toString(), "M") == 7) && (DateTimeUtil
                .getYearMonthDate(date.toString(), "D") == 1))) {
            i = true;
        }
        return i;
    }
    /**
     * 取半年的第一天
     * @param date
     * @return
     */
    public static String getHalfYearFirstDay(java.sql.Date date) {
        String month = "01";
        if (DateTimeUtil.getYearMonthDate(date.toString(), "M") >= 7) {
            month = "07";
        }
        String day = Integer.toString(DateTimeUtil.getYearMonthDate(
                date.toString(), "Y")) + "-" + month + "-01";
        return day;
    }
    /**
     * 是否是半年最后一天
     * */
    public static boolean isHalfYearLastDay(java.sql.Date date) {
        boolean i = false;
        if (((DateTimeUtil.getYearMonthDate(date.toString(), "M") == 12) && (DateTimeUtil
                .getYearMonthDate(date.toString(), "D") == 31))
                || ((DateTimeUtil.getYearMonthDate(date.toString(), "M") == 6) && (DateTimeUtil
                .getYearMonthDate(date.toString(), "D") == 30))) {
            i = true;
        }
        return i;
    }
    /***
     * 取半年最后一天
     * @param date
     * @return
     */
    public static String getHalfYearLastDay(java.sql.Date date) {
        String month = "-06-30";
        if (DateTimeUtil.getYearMonthDate(date.toString(), "M") >= 7) {
            month = "-12-31";
        }
        String day = Integer.toString(getYearMonthDate(date.toString(), "Y"))
                + "-" + month;
        return day;
    }
 
    /***
     *是否是年度最后一天
     * @param date
     * @return
     */
    public static boolean isYearLastDay(java.sql.Date date) {
        boolean i = false;
        if ((DateTimeUtil.getYearMonthDate(date.toString(), "M") == 12)
                && (DateTimeUtil.getYearMonthDate(date.toString(), "D") == 31)) {
            i = true;
        }
        return i;
    }
 
    /**
     * 是否季度第一天
     * */
    public static boolean isQuarterFirstDay(java.sql.Date date) {
        boolean i = false;
        if (((DateTimeUtil.getYearMonthDate(date.toString(), "M") == 1)
                || (DateTimeUtil.getYearMonthDate(date.toString(), "M") == 4)
                || (DateTimeUtil.getYearMonthDate(date.toString(), "M") == 7) || (DateTimeUtil
                .getYearMonthDate(date.toString(), "M") == 10))
                && (DateTimeUtil.getYearMonthDate(date.toString(), "D") == 1)) {
            i = true;
        }
        return i;
    }
    /***
     * 季度第一天
     * @param date
     * @return
     */
    public static String getQuarterFirstDay(java.sql.Date date) {
        String month = "01";
        if (DateTimeUtil.getYearMonthDate(date.toString(), "M") >= 10) {
            month = "10";
        } else if (DateTimeUtil.getYearMonthDate(date.toString(), "M") >= 7) {
            month = "07";
        } else if (DateTimeUtil.getYearMonthDate(date.toString(), "M") >= 4) {
            month = "04";
        } else if (DateTimeUtil.getYearMonthDate(date.toString(), "M") >= 1) {
            month = "01";
        }
 
        String day = Integer.toString(DateTimeUtil.getYearMonthDate(
                date.toString(), "Y")) + "-" + month + "-01";
        return day;
    }
 
 
    /**
     * 是否季度最后一天
     * @param date
     * @return
     */
    public static boolean isQuarterLastDay(java.sql.Date date) {
        boolean i = false;
        if ((DateTimeUtil.getYearMonthDate(date.toString(), "M") == 3)
                && (DateTimeUtil.getYearMonthDate(date.toString(), "D") == 31)) {
            i = true;
        }
        if ((DateTimeUtil.getYearMonthDate(date.toString(), "M") == 6)
                && (DateTimeUtil.getYearMonthDate(date.toString(), "D") == 30)) {
            i = true;
        }
        if ((DateTimeUtil.getYearMonthDate(date.toString(), "M") == 9)
                && (DateTimeUtil.getYearMonthDate(date.toString(), "D") == 30)) {
            i = true;
        }
        if ((DateTimeUtil.getYearMonthDate(date.toString(), "M") == 12)
                && (DateTimeUtil.getYearMonthDate(date.toString(), "D") == 31)) {
            i = true;
        }
        return i;
    }
    /**
     * 季度最后一天
     * @param date
     * @return
     */
    public static String getQuarterLastDay(java.sql.Date date) {
        String month = "-03-31";
        if (DateTimeUtil.getYearMonthDate(date.toString(), "M") >= 10) {
            month = "-12-31";
        } else if (DateTimeUtil.getYearMonthDate(date.toString(), "M") >= 7) {
            month = "-09-30";
        } else if (DateTimeUtil.getYearMonthDate(date.toString(), "M") >= 4) {
            month = "-06-30";
        }
 
        String day = Integer.toString(DateTimeUtil.getYearMonthDate(
                date.toString(), "Y")) + "-" + month;
        return day;
    }
 
    /***
     * 是否月份最后一天
     * @param date
     * @return
     */
    public static boolean isMonthLastDay(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.getActualMaximum(Calendar.DAY_OF_MONTH) == calendar.get(Calendar.DAY_OF_MONTH);
    }
 
    /**
     * 是否月份第一天
     * @param date
     * @return
     */
    public static boolean isMonthFisrtDay(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.getActualMinimum(Calendar.DAY_OF_MONTH) == calendar.get(Calendar.DAY_OF_MONTH);
    }
 
    /**
     * 月份第一天日期
     * @param date
     * @return
     */
    public static Date getMonthFisrtDay(Date date){
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
        return calendar.getTime();
    }
 
    /**
     * 星期的第几天
     * @param strDate  yy-mm-dd
     * @return
     */
    public static int getDateInWeek(String strDate) {
        DateFormat df = DateFormat.getDateInstance();
        try {
            df.parse(strDate);
            Calendar c = df.getCalendar();
            int day = c.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY;
            return day;
        } catch (ParseException e) {
            return -1;
        }
    }
 
 
    public static java.sql.Date getSqlDate(Date date) {
        java.sql.Date result = null;
        try {
            SimpleDateFormat myFormat = new SimpleDateFormat(LONGFORMAT);
            String mystrdate = myFormat.format(date);
            result = java.sql.Date.valueOf(mystrdate);
        } catch (Exception e) {
            return null;
        }
        return result;
    }
 
    /**
     * 获取当前月的月初到今天的日期
     */
//    public static List<String> getDayofMouth() {
//        List<String> data = new ArrayList<>();
//
//    }
 
    /**
     * 获取当月所有日期
     * @return
     */
    public static List<String> getDayByMonth(String yearStr, String monthStr){
        List<String> data = new ArrayList<>();
     try {
        Calendar c = Calendar.getInstance();
        // 获取当前的年份
         c.set(Calendar.YEAR, Integer.valueOf(yearStr));
        // 获取当前的月份(需要加1才是现在的月份)
         c.set(Calendar.YEAR, Integer.valueOf(monthStr) - 1);
        // 获取本月的总天数
        int dayCount = c.getActualMaximum(Calendar.DAY_OF_MONTH);
        // 定义时间格式
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        // 开始日期为当前年月拼接1号
        Date startDate = sdf.parse(yearStr + "-" + monthStr + "-01");
        // 结束日期为当前年月拼接该月最大天数
        Date endDate = sdf.parse(yearStr + "-" + monthStr + "-" + dayCount);
        // 设置calendar的开始日期
        c.setTime(startDate);
        // 当前时间小于等于设定的结束时间
        while(c.getTime().compareTo(endDate) <= 0){
            String time = sdf.format(c.getTime());
            data.add(time);
            // 当前日期加1
            c.add(Calendar.DATE, 1);
        }
    } catch (ParseException e) {
        e.printStackTrace();
    }
 
        return data;
}
 
 
    /**
     * 上个月
     * @param dt
     * @return
     */
    @SuppressWarnings("deprecation")
    public static String getUpMDate(Date dt) {
        dt.setDate(1);
        dt.setDate(dt.getDate() - 1);
        return dt.toLocaleString();
    }
 
 
    public static String getShortDate(String dt) {
        if (dt != null) {
            SimpleDateFormat myFormat = new SimpleDateFormat(SHORTFORMAT);
            try {
                Date date = myFormat.parse(dt);
                return getDate(date, SHORTFORMATNOSPIT);
            } catch (ParseException e) {
                return dt;
            }
        } else
            return dt;
    }
 
 
    public static String getLongDate(String dt) {
        if (dt != null) {
            SimpleDateFormat myFormat = new SimpleDateFormat(SHORTFORMAT);
            try {
                Date date = myFormat.parse(dt);
                return getDate(date, SHORTFORMAT);
            } catch (ParseException e) {
                return dt;
            }
        } else
            return dt;
    }
 
 
    public static boolean isSameYearMonth(String date) {
        try {
            String currdate = getDate();
            currdate = getShortDate(currdate).substring(0, 6);
            String lastdate = getShortDate(date).substring(0, 6);
            if (lastdate.equals(currdate)) {
                return true;
            } else {
                return false;
            }
        } catch (NumberFormatException e) {
            return false;
        }
    }
}