Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add format method to concrete datetime classes #239

Closed
RogerRiggs opened this Issue · 4 comments

2 participants

@RogerRiggs
Collaborator

For improved usability, concrete date-time classes with a format (aka print) method should also have a format method that takes the pattern as an argument, i.e. format("yyyy-mm-dd").

(Exracted from issue #210)

@jodastephen
Owner

This isn't something I fully understand, and I'm not sure I agree with. To be complete you need two methods (a variant taking a locale).

Are we talking about classes like LocalDate? or just DateTimeFormatter? (which is the only class with a format method.

@RogerRiggs
Collaborator

The proposal was to make classes like LocalDate, LocalTime more format friendly by providing a direct method with a pattern, for example:

LocalDateTime ldt =;
String s = ldt.format("yyyy");

This is low priority given the limited time we have left.

@jodastephen
Owner

Its two additional methods for each concrete class. I did it in Joda-Time, but I don't think it really paid its way.

@RogerRiggs
Collaborator

Defer adding another convenience method. With the rename of print to format, the code can be
date.format(DateTimeFormatter.ofPattern(""yyyy-mm-dd")).
Or reuse a predefined formatter:
date.format(DateTimeFormatter.ISO_DATE)

@RogerRiggs RogerRiggs closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.