I need a new instance which is a copy. I could create an instance from integers, but it seems that there should be a more direct way. I could also use some kind of approach like copy = original.minus(zero) , but this is also indirect.
The LocalTime constructor that takes a Java Object argument (for which I used the original LocalTime) does not work. I think it just does not support.
LocalTime start = new LocalTime(9, 0, 0); LocalTime stop = new LocalTime(17, 0, 0); //LocalTime time = start.minusSeconds(0); // GOOD VERSION LocalTime time = new LocalTime(start); // THE BAD VERSION assert time == start: "does not work"; // EXTRANEOUS STUFF TO JUSTIFY COPYING AN IMMUTABLE, FOLLOWS... while (time.compareTo(stop) <= 0) { //method(time, new LocalTime(9, 0, 0), stop); // MESSY method(time, start, stop); // NICER time = time.plusMinutes(1); }
I also tried copy = new LocalTime(original.getLocalMillis()) , but I do not have access to getLocalMillis as it is protected.
source share