Time manipulation with Joda Time [duplicate]

0
 String tempo1 = "01:30:30";
 String tempo2 = "24:25:10";

    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
    try {
        Date date1 = (Date)sdf.parse(tempo1);
        Date date2 = (Date)sdf.parse(tempo2);

        DateTime dateTime1 = new DateTime(date1);
        DateTime dateTime2 = new DateTime(date2);

Personally, how do I add these two strings as follows: "25:55:40"?

It's always coming back 01:55:40.

    
asked by anonymous 30.03.2016 / 02:16

1 answer

0

Using JodaTime I think the following function would solve your problem:

private DateTime somarTempos(DateTime t1, DateTime t2) {
    return t1.plusHours(t2.getHourOfDay())
            .plusMinutes(t2.getMinuteOfHour())
            .plusSeconds(t2.getSecondOfMinute());
}
    
30.03.2016 / 13:47