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

Result Date Format #2

Open
willpowr opened this issue Feb 19, 2017 · 2 comments
Open

Result Date Format #2

willpowr opened this issue Feb 19, 2017 · 2 comments

Comments

@willpowr
Copy link

By default it appears that if a date 1/6/2017 is parsed, the output of result.date is Year=2017,Month=1,DayOfMonth=6. (US format 6th January 2017)

Is there a way to specify that the same input should be parsed to Year=2017,Month=6,DayOf Month=1 (UK format 1st June 2017)?

@suseek
Copy link

suseek commented Mar 18, 2019

Have exactly the same issue, cannot specify en_GB which appears on your JS library.

@suseek
Copy link

suseek commented Mar 18, 2019

@willpowr best would be to just implement your own ENSlashDateFormatParser and these two lines (42, 43) switch the groups, so at the end, it would look like this

        int day = Integer.parseInt(matcher.group(3));
        int month = Integer.parseInt(matcher.group(4));

then just

ChronoOption options = ChronoOption.standardOptions();
        options.parsers.add(new ENGBSlashDateFormatParser());
        new Chrono(options).parse("01/06/2017");

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

No branches or pull requests

2 participants