java.time: update threeten code and tests WRT JDK semantics

This commit is contained in:
Alexey Andreev 2021-03-17 22:41:01 +03:00
parent 8fea07b772
commit 44bacd0b02
2 changed files with 19 additions and 14 deletions

View File

@ -1672,12 +1672,19 @@ public final class DateTimeFormatterBuilder {
case 'D': case 'D':
if (count == 1) { if (count == 1) {
appendValue(field); appendValue(field);
} else if (count <= 3) { } else if (count == 2) {
appendValue(field, 2, 3, SignStyle.NOT_NEGATIVE);
} else if (count == 3) {
appendValue(field, count); appendValue(field, count);
} else { } else {
throw new IllegalArgumentException("Too many pattern letters: " + cur); throw new IllegalArgumentException("Too many pattern letters: " + cur);
} }
break; break;
case 'N':
case 'n':
case 'A':
appendValue(field, count, 19, SignStyle.NOT_NEGATIVE);
break;
default: default:
if (count == 1) { if (count == 1) {
appendValue(field); appendValue(field);

View File

@ -417,8 +417,6 @@ public class TestDateTimeFormatterBuilder {
{"HH:MM:ss"}, {"HH:MM:ss"},
{"HHMMSS"}, {"HHMMSS"},
{"HH:MM:SS"}, {"HH:MM:SS"},
{"+H"},
{"+HMM"},
{"+HHM"}, {"+HHM"},
{"+A"}, {"+A"},
}; };
@ -619,7 +617,7 @@ public class TestDateTimeFormatterBuilder {
// {"www", "Value(WeekOfWeekBasedYear,3)"}, // {"www", "Value(WeekOfWeekBasedYear,3)"},
{"D", "Value(DayOfYear)"}, {"D", "Value(DayOfYear)"},
{"DD", "Value(DayOfYear,2)"}, {"DD", "Value(DayOfYear,2,3,NOT_NEGATIVE)"},
{"DDD", "Value(DayOfYear,3)"}, {"DDD", "Value(DayOfYear,3)"},
{"d", "Value(DayOfMonth)"}, {"d", "Value(DayOfMonth)"},
@ -658,17 +656,17 @@ public class TestDateTimeFormatterBuilder {
{"SSS", "Fraction(NanoOfSecond,3,3)"}, {"SSS", "Fraction(NanoOfSecond,3,3)"},
{"SSSSSSSSS", "Fraction(NanoOfSecond,9,9)"}, {"SSSSSSSSS", "Fraction(NanoOfSecond,9,9)"},
{"A", "Value(MilliOfDay)"}, {"A", "Value(MilliOfDay,1,19,NOT_NEGATIVE)"},
{"AA", "Value(MilliOfDay,2)"}, {"AA", "Value(MilliOfDay,2,19,NOT_NEGATIVE)"},
{"AAA", "Value(MilliOfDay,3)"}, {"AAA", "Value(MilliOfDay,3,19,NOT_NEGATIVE)"},
{"n", "Value(NanoOfSecond)"}, {"n", "Value(NanoOfSecond,1,19,NOT_NEGATIVE)"},
{"nn", "Value(NanoOfSecond,2)"}, {"nn", "Value(NanoOfSecond,2,19,NOT_NEGATIVE)"},
{"nnn", "Value(NanoOfSecond,3)"}, {"nnn", "Value(NanoOfSecond,3,19,NOT_NEGATIVE)"},
{"N", "Value(NanoOfDay)"}, {"N", "Value(NanoOfDay,1,19,NOT_NEGATIVE)"},
{"NN", "Value(NanoOfDay,2)"}, {"NN", "Value(NanoOfDay,2,19,NOT_NEGATIVE)"},
{"NNN", "Value(NanoOfDay,3)"}, {"NNN", "Value(NanoOfDay,3,19,NOT_NEGATIVE)"},
{"z", "ZoneText(SHORT)"}, {"z", "ZoneText(SHORT)"},
{"zz", "ZoneText(SHORT)"}, {"zz", "ZoneText(SHORT)"},
@ -694,7 +692,7 @@ public class TestDateTimeFormatterBuilder {
{"xxxxx", "Offset(+HH:MM:ss,'+00:00')"}, {"xxxxx", "Offset(+HH:MM:ss,'+00:00')"},
{"ppH", "Pad(Value(HourOfDay),2)"}, {"ppH", "Pad(Value(HourOfDay),2)"},
{"pppDD", "Pad(Value(DayOfYear,2),3)"}, {"pppDD", "Pad(Value(DayOfYear,2,3,NOT_NEGATIVE),3)"},
{"uuuu[-MM[-dd", "Value(Year,4,19,EXCEEDS_PAD)['-'Value(MonthOfYear,2)['-'Value(DayOfMonth,2)]]"}, {"uuuu[-MM[-dd", "Value(Year,4,19,EXCEEDS_PAD)['-'Value(MonthOfYear,2)['-'Value(DayOfMonth,2)]]"},
{"uuuu[-MM[-dd]]", "Value(Year,4,19,EXCEEDS_PAD)['-'Value(MonthOfYear,2)['-'Value(DayOfMonth,2)]]"}, {"uuuu[-MM[-dd]]", "Value(Year,4,19,EXCEEDS_PAD)['-'Value(MonthOfYear,2)['-'Value(DayOfMonth,2)]]"},