zappee :
I would like to create a copy java.time.LocalDateTime
but it does not have clone()
method.
What I do is the following:
long epochMilli = Instant.now().toEpochMilli();
LocalDateTime createDate = LocalDateTime.ofInstant(Instant.ofEpochMilli(epochMilli), ZoneId.systemDefault());
LocalDateTime modificationDate = LocalDateTime.ofInstant(Instant.ofEpochMilli(epochMilli), ZoneId.systemDefault());
Is there an easyest way to create two LocalDateTime objects with the exact same date-time value?
Jacob G. :
Because LocalDateTime
is immutable, you can simply reference the same object:
LocalDateTime createDate = LocalDateTime.now();
LocalDateTime modificationDate = createDate;