|
@@ -480,4 +480,31 @@ public class DateUtil {
|
480
|
480
|
return calendar.get(Calendar.WEEK_OF_YEAR);
|
481
|
481
|
}
|
482
|
482
|
|
|
483
|
+ /**
|
|
484
|
+ * 获取当前时间
|
|
485
|
+ * @return
|
|
486
|
+ * @throws ParseException
|
|
487
|
+ */
|
|
488
|
+ public static Date getTime()throws ParseException{
|
|
489
|
+ Date time = Calendar.getInstance().getTime();
|
|
490
|
+ SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
491
|
+ String format = dateFormat.format(time);
|
|
492
|
+ Date date = dateFormat.parse(format);
|
|
493
|
+ return date;
|
|
494
|
+ }
|
|
495
|
+
|
|
496
|
+ /**
|
|
497
|
+ * 获取上一个月的日期
|
|
498
|
+ * @return
|
|
499
|
+ * @throws ParseException
|
|
500
|
+ */
|
|
501
|
+ public static String getLastMonth(){
|
|
502
|
+ Calendar c = Calendar.getInstance();
|
|
503
|
+ SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd");
|
|
504
|
+ c.setTime(new Date());
|
|
505
|
+ c.add(Calendar.MONTH, -1);
|
|
506
|
+ Date m = c.getTime();
|
|
507
|
+ String mon = dateFormat.format(m);
|
|
508
|
+ return mon;
|
|
509
|
+ }
|
483
|
510
|
}
|