-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Fix java date parsing to be compatible with joda #36155
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
import java.util.Locale; | ||
|
||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.equalTo; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused import |
||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.startsWith; | ||
|
||
|
@@ -390,6 +391,28 @@ public void testDuelingStrictParsing() { | |
|
||
assertSameDate("2012-W31-5", "strict_weekyear_week_day"); | ||
assertParseException("2012-W1-1", "strict_weekyear_week_day"); | ||
//failing below | ||
assertSameDate("2015-01-04T00:00Z", "strict_date_optional_time||epoch_millis"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you just use Can you also move this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. absolutely - will clean this up |
||
} | ||
//Failing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will delete these if the PR is ok, but it helps investigating There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for sure I'm fine with the PR in general! :-) |
||
public void testFailingParseJavaTime(){ | ||
DateFormatter formatter = DateFormatters.forPattern("strict_date_optional_time||epoch_millis"); | ||
TemporalAccessor parse = formatter.parse("2015-01-04T00:00Z"); | ||
} | ||
//Passing | ||
public void testParsingJoda(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these two methods are not needed anymore, correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are not needed. I only left them if you wanted to verify that quickly on your own |
||
FormatDateTimeFormatter formatter = Joda.forPattern("strict_date_optional_time||epoch_millis"); | ||
DateTime dateTime = formatter.parser().parseDateTime("2015-01-04T00:00Z"); | ||
assertThat(dateTime, | ||
equalTo(new DateTime() | ||
.withZone(DateTimeZone.UTC) | ||
.withYear(2015) | ||
.withMonthOfYear(1) | ||
.withDayOfMonth(4) | ||
.withHourOfDay(0) | ||
.withMinuteOfHour(0) | ||
.withMillisOfDay(0) | ||
)); | ||
} | ||
|
||
public void testSamePrinterOutput() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is just moving the zoneId below the optional section of seconds/milliseconds. Hard to see with this formatting