This repository has been archived by the owner. It is now read-only.

Add format method to concrete datetime classes #239

Closed
RogerRiggs opened this Issue Jan 29, 2013 · 4 comments

Comments

Projects
None yet
2 participants
@RogerRiggs
Contributor

RogerRiggs commented Jan 29, 2013

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

This comment has been minimized.

Show comment Hide comment
@jodastephen

jodastephen Jan 29, 2013

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.

Owner

jodastephen commented Jan 29, 2013

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

This comment has been minimized.

Show comment Hide comment
@RogerRiggs

RogerRiggs Jan 29, 2013

Contributor

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.

Contributor

RogerRiggs commented Jan 29, 2013

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

This comment has been minimized.

Show comment Hide comment
@jodastephen

jodastephen Jan 29, 2013

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.

Owner

jodastephen commented Jan 29, 2013

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

This comment has been minimized.

Show comment Hide comment
@RogerRiggs

RogerRiggs Apr 2, 2013

Contributor

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)

Contributor

RogerRiggs commented Apr 2, 2013

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 Apr 2, 2013

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.