获取 当前日期、当前时间、前一天日期
生活随笔
收集整理的這篇文章主要介紹了
获取 当前日期、当前时间、前一天日期
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
/*** 獲取前一天日期** @return*/public String getYesterday() {Calendar calendar = Calendar.getInstance();calendar.add(Calendar.DATE, -1); //得到前一天Date date = calendar.getTime();DateFormat df = new SimpleDateFormat("yyyy-MM-dd");return df.format(date);}/*** 獲取當(dāng)前日期** @return*/public String getCurrentDate() {LocalDateTime dateTime = LocalDateTime.now();DateTimeFormatter currentDate = DateTimeFormatter.ofPattern("yyyy-MM-dd");return dateTime.format(currentDate);}/*** 獲取當(dāng)前時間** @return*/public String getCurrentTime() {LocalDateTime dateTime = LocalDateTime.now();DateTimeFormatter currenTime = DateTimeFormatter.ofPattern("HH:mm:ss");return dateTime.format(currenTime);}
Hxprocesslog hxprocesslog = new Hxprocesslog();
// Date tStartDate = new Date();
// DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
// DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
// hxprocesslog.setMakedate(dateFormat.parse(dateFormat.format(tStartDate)));
// hxprocesslog.setMaketime(timeFormat.format(tStartDate));
// hxprocesslog.setModifytime(timeFormat.format(tStartDate));
// hxprocesslog.setModifydate(dateFormat.parse(dateFormat.format(tStartDate)));
總結(jié)
以上是生活随笔為你收集整理的获取 当前日期、当前时间、前一天日期的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: TortoiseGit 单文件版本对比_
- 下一篇: SpringBoot 整合 Redis