JAVA将时间串18:00:00和日期年月日合并起来

论坛 期权论坛 脚本     
匿名技术用户   2020-12-29 01:27   64   0
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

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP