Java : how to add 10 mins in my Time

前端 未结 8 1905
闹比i
闹比i 2020-11-27 21:00

I am getting this time

String myTime = \"14:10\";

Now I want to add like 10 mins to this time, so that it would be 14:20

8条回答
  •  误落风尘
    2020-11-27 21:14

    Java 7 Time API

        DateTimeFormatter df = DateTimeFormatter.ofPattern("HH:mm");
    
        LocalTime lt = LocalTime.parse("14:10");
        System.out.println(df.format(lt.plusMinutes(10)));
    

提交回复
热议问题