my-csc-config-file.git 3 年之前
父节点
当前提交
a74d5be53c
共有 2 个文件被更改,包括 60 次插入6 次删除
  1. 3 0
      src/main/java/com/unissoft/MyConstant.java
  2. 57 6
      src/main/java/com/unissoft/utils/DateUtil.java

+ 3 - 0
src/main/java/com/unissoft/MyConstant.java

@@ -29,6 +29,8 @@ public class MyConstant {
29 29
     public static final int TWO = 2;
30 30
     public static final int THREE = 3;
31 31
     public static final int FOUR = 4;
32
+    public static final int SIXTY = 60;
33
+    public static final double ZERO_POINT_FIVE = 0.5;
32 34
     public static final String ONE_STR = "1";
33 35
     public static final String THREE_STR = "3";
34 36
 
@@ -41,6 +43,7 @@ public class MyConstant {
41 43
     public static final String BURDEN_ZERO = "-00";
42 44
 
43 45
     public static final String LOGIN_USER = "loginUser";
46
+    public static final String SPECIFIC_TIME = "specificTime";
44 47
     //请求认证头
45 48
     public static final String AUTHORIZATION = "Authorization";
46 49
 

+ 57 - 6
src/main/java/com/unissoft/utils/DateUtil.java

@@ -482,29 +482,80 @@ public class DateUtil {
482 482
 
483 483
     /**
484 484
      * 获取当前时间
485
+     *
485 486
      * @return
486 487
      * @throws ParseException
487 488
      */
488
-    public static Date getTime()throws ParseException{
489
+    public static Date getTime() throws ParseException {
489 490
         Date time = Calendar.getInstance().getTime();
490
-        SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd HH:mm");
491
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
491 492
         String format = dateFormat.format(time);
492 493
         Date date = dateFormat.parse(format);
493
-       return date;
494
+        return date;
495
+    }
496
+
497
+    /**
498
+     * 获取当前时间年月
499
+     *
500
+     * @return
501
+     * @throws ParseException
502
+     */
503
+    public static Date getSpecificTime() {
504
+        Date date = null;
505
+        try {
506
+            Date time = Calendar.getInstance().getTime();
507
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
508
+            String format = dateFormat.format(time);
509
+            date = dateFormat.parse(format);
510
+        } catch (ParseException e) {
511
+            e.printStackTrace();
512
+        }
513
+        return date;
514
+    }
515
+
516
+    /**
517
+     * 获取当前时间年月日
518
+     *
519
+     * @return
520
+     * @throws ParseException
521
+     */
522
+    public static Date getDayTime() {
523
+        Date date = null;
524
+        try {
525
+            Date time = Calendar.getInstance().getTime();
526
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
527
+            String format = dateFormat.format(time);
528
+            date = dateFormat.parse(format);
529
+        } catch (ParseException e) {
530
+            e.printStackTrace();
531
+        }
532
+        return date;
494 533
     }
495 534
 
496 535
     /**
497 536
      * 获取上一个月的日期
537
+     *
498 538
      * @return
499 539
      * @throws ParseException
500 540
      */
501
-    public static String getLastMonth(){
541
+    public static String getLastMonth() {
502 542
         Calendar c = Calendar.getInstance();
503
-        SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd");
543
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
504 544
         c.setTime(new Date());
505 545
         c.add(Calendar.MONTH, -1);
506 546
         Date m = c.getTime();
507 547
         String mon = dateFormat.format(m);
508
-       return mon;
548
+        return mon;
549
+    }
550
+
551
+    /**
552
+     * 获取当月的 天数
553
+     */
554
+    public static int getCurrentMonthDay() {
555
+        Calendar a = Calendar.getInstance();
556
+        a.set(Calendar.DATE, 1);
557
+        a.roll(Calendar.DATE, -1);
558
+        int maxDate = a.get(Calendar.DATE);
559
+        return maxDate;
509 560
     }
510 561
 }