Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TemporalFactories #166

Open
jodastephen opened this issue Nov 29, 2020 · 4 comments
Open

Add TemporalFactories #166

jodastephen opened this issue Nov 29, 2020 · 4 comments
Labels

Comments

@jodastephen
Copy link
Member

jodastephen commented Nov 29, 2020

Consider adding a class TemporalFactories (name TBD). It would have factory methods for all temporal classes across java.time and ThreeTen-Extra. The crucial difference would be that such a class would be designed for static imports:

public class TemporalFactories {
  public LocalDate date(int,int,int);
  public LocalDate date(int,Month,int);
  public LocalDate date(int,MonthDay);
  public LocalDate date(int,int);
  public LocalDate date(Year,int,int);
  public LocalDate date(Year,Month,int);
  public LocalDate date(Year,MonthDay);
  public LocalDate date(Year,int);
  public LocalDate date(String);  // parse
  // and so on for other types
}
// usage
callMethod(date(2020, 6, 12));

Originally suggested in #155

@raupachz
Copy link
Contributor

That would definitely make some parts of the code I write more concise and less verbose.

Unless anyone objects, I would like to spend some time on this.

@jodastephen
Copy link
Member Author

I'd love to see this - they'll be quite a lot of methods, so I'd suggest simple Javadoc simply repeating the implementation as an @code

@mjustin
Copy link
Contributor

mjustin commented Aug 24, 2021

@jodastephen I notice that LocalDate.from(TemporalAccessor temporal) is missing from the list. Would you expect this to be in this class, or for it to be excluded from this class?

public static LocalDate date(TemporalAccessor from)

@jodastephen
Copy link
Member Author

Excluded. Conversion methods should need more care to use than of methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants