Skip to content

Commit bcc97bf

Browse files
paulfthomaspekingme
authored andcommitted
[MaterialDatePicker] Fix hint for Korean
PiperOrigin-RevId: 520025180
1 parent dfbf4d9 commit bcc97bf

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/java/com/google/android/material/datepicker/UtcDates.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ static String getDefaultTextInputHint(Resources res, SimpleDateFormat format) {
172172
formatHint = formatHint.replace("y", "yyyy");
173173
}
174174

175+
// Remove duplicate year characters for Korean.
176+
if (Locale.getDefault().getLanguage().equals(Locale.KOREAN.getLanguage())) {
177+
formatHint = formatHint.replaceAll("y+", "y");
178+
}
179+
175180
return formatHint.replace("d", dayChar).replace("M", monthChar).replace("y", yearChar);
176181
}
177182

lib/javatests/com/google/android/material/datepicker/UtcDatesTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,13 @@ public void textInputHintWith1CharYearLocalized() {
7474

7575
assertEquals("m/j/aaaa", hint);
7676
}
77+
78+
@Test
79+
@Config(qualifiers = "ko")
80+
public void textInputHintForKorean() {
81+
SimpleDateFormat sdf = new SimpleDateFormat("yy.M.d.");
82+
String hint = UtcDates.getDefaultTextInputHint(context.getResources(), sdf);
83+
84+
assertEquals("년.월.일.", hint);
85+
}
7786
}

0 commit comments

Comments
 (0)