Jodatime work alone with hours and minutes

1

I am working on a project in which I have to add hours from a set time as:

  

00:00

this data is a String to which I must go adding hours and minutes related to some work parts.
I'm using Jodatime that I think is more useful than adding up the hours, minutes ... What I'm doing is creating a LocalDateTime object that I want to add to, but I can not find it on a day at 00:00:

  LocalDateTime parteLocalHoraFinDt = new LocalDateTime();
        parteLocalHoraFinDt.withHourOfDay(0);
        parteLocalHoraFinDt.withMinuteOfHour(0);
        parteLocalHoraFinDt.withSecondOfMinute(0);

What am I doing wrong? Any other ideas to add hours to a String "00:00"?

    
asked by JoCuTo 07.03.2018 в 19:13
source

1 answer

0

Always try to use a library to see its documentation

The methods with... say in their documentation that they return a copy, they do not modify the original object:

  

Returns to a copy of this datetime with the hour of day field updated.

Moreover, the same LocalDateTime class says that it is immutable:

  

LocalDateTime is an unmodifiable datetime class representing a   datetime without a time zone.

To use it you must use what returns:

LocalDateTime parteLocalHoraFinDt = new LocalDateTime()
        .withHourOfDay(0)
        .withMinuteOfHour(0)
        .withSecondOfMinute(0);

That style of interface is known as fluent

    
answered by 07.03.2018 / 19:23
source