threeten-extra: Why doesn't LocalDateTime have plus/minusMilliseconds()?

Out of curiosity, why does LocalDateTime have plus/minus hours, minutes, second and even nanoseconds, but not milliseconds? Is there a technical reason for this? Can it be added?

Yes, I am familiar with plus(long amountToAdd, TemporalUnit unit) but I’m wondering why all other units have dedicated methods and milliseconds does not.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

How does plusMillis() differ from plusSeconds() in this regard? If you’re going to have one, you should really have the other.

I see where you’re coming from, but it sounds like you’re letting implementation details dictate API design/usability. Just because there is no underlying field for milliseconds doesn’t mean that the API should not have a getter method.

Do users add/subtract milliseconds on a regular basis? If so, I would advocate adding this method.

I know for that for most time classes (especially the ones that measure time in terms of milliseconds from epoc) milliseconds manipulation is fairly common. In my case, I’ve got two LocalDateTime instances that represent a time range. For the exclusive endpoint, I need to calculate the inclusive endpoint that predates it (time - 1 millisecond) in order to convert it into an SQL statement.