SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date now = new Date();
SimpleDateFormat ds = new SimpleDateFormat("yyyy-MM-dd ");
Date startTime = df.parse(ds.format(now) +"18:00:00");startTime = 2018-01-19 18:00:00
当前日期加一天 并且和 时间串合并:
Calendar c = Calendar.getInstance();
c.setTime(now);
c.add(Calendar.DAY_OF_MONTH, 1);
Date endTime = df.parse(ds.format(c.getTime()) + "18:00:00");endTime = 2018-01-20 18:00:00
本文介绍如何使用Java中的SimpleDateFormat类来格式化日期和时间,并演示了如何获取当前日期及时间,以及如何对日期进行加一天的操作。
1138





