mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix how weeks are represented in DateFormatSymbols
Add missing methods to DateFormatSymbols
This commit is contained in:
parent
6c75ce7f68
commit
26db1acc96
|
@ -46,6 +46,9 @@ abstract class TDateFormatElement {
|
|||
|
||||
static int whichMatches(String text, TParsePosition position, String[] patterns) {
|
||||
for (int i = 0; i < patterns.length; ++i) {
|
||||
if (patterns[i] == null) {
|
||||
continue;
|
||||
}
|
||||
if (matches(text, position.getIndex(), patterns[i])) {
|
||||
position.setIndex(position.getIndex() + patterns[i].length());
|
||||
return i;
|
||||
|
@ -117,7 +120,7 @@ abstract class TDateFormatElement {
|
|||
|
||||
@Override
|
||||
public void format(TCalendar date, StringBuffer buffer) {
|
||||
int weekday = date.get(TCalendar.DAY_OF_WEEK) - 1;
|
||||
int weekday = date.get(TCalendar.DAY_OF_WEEK);
|
||||
buffer.append(abbreviated ? shortWeeks[weekday] : weeks[weekday]);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ public class TDateFormatSymbols implements TSerializable, TCloneable {
|
|||
String[] weekdays;
|
||||
String[][] zoneStrings;
|
||||
|
||||
|
||||
public TDateFormatSymbols() {
|
||||
this(TLocale.getDefault());
|
||||
}
|
||||
|
@ -146,14 +145,22 @@ public class TDateFormatSymbols implements TSerializable, TCloneable {
|
|||
|
||||
public String[] getShortWeekdays() {
|
||||
if (shortWeekdays == null) {
|
||||
shortWeekdays = CLDRHelper.resolveShortWeekdays(locale.getLanguage(), locale.getCountry());
|
||||
shortWeekdays = new String[8];
|
||||
String[] cldrWeekdays = CLDRHelper.resolveShortWeekdays(locale.getLanguage(), locale.getCountry());
|
||||
for (int i = 0; i < 7; ++i) {
|
||||
shortWeekdays[i + 1] = cldrWeekdays[i];
|
||||
}
|
||||
}
|
||||
return shortWeekdays.clone();
|
||||
}
|
||||
|
||||
public String[] getWeekdays() {
|
||||
if (weekdays == null) {
|
||||
weekdays = CLDRHelper.resolveWeekdays(locale.getLanguage(), locale.getCountry());
|
||||
weekdays = new String[8];
|
||||
String[] cldrWeekdays = CLDRHelper.resolveWeekdays(locale.getLanguage(), locale.getCountry());
|
||||
for (int i = 0; i < 7; ++i) {
|
||||
weekdays[i + 1] = cldrWeekdays[i];
|
||||
}
|
||||
}
|
||||
return weekdays.clone();
|
||||
}
|
||||
|
@ -235,4 +242,8 @@ public class TDateFormatSymbols implements TSerializable, TCloneable {
|
|||
public void setZoneStrings(String[][] data) {
|
||||
zoneStrings = data.clone();
|
||||
}
|
||||
|
||||
public static TDateFormatSymbols getInstance(TLocale locale) {
|
||||
return new TDateFormatSymbols(locale);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user