Make ScheduleConfigTest pass in non-US locales
Gerrit's documentation states that it wants Mondays abbreviated as 'Mon' for gc.startTime, but the parsing code tried to parse the abbreviated week day in default locale. As non-US locales need not parse 'Mon' to a Monday (E.g.: German uses 'Mo' as abbreviation for Monday and chokes on 'Mon'), we parse using the US locale. Thereby, we make the code do what the docs require, and we make the ScheduleConfigTest pass, if the default locale has different abbreviations for Mondays. Change-Id: I06e5b0e4299424dbcb5f0f9628b374b619e3c16f
This commit is contained in:
@@ -28,6 +28,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ScheduleConfig {
|
||||
@@ -122,7 +123,8 @@ public class ScheduleConfig {
|
||||
startTime.hourOfDay().set(firstStartTime.getHourOfDay());
|
||||
startTime.minuteOfHour().set(firstStartTime.getMinuteOfHour());
|
||||
} catch (IllegalArgumentException e1) {
|
||||
formatter = DateTimeFormat.forPattern("E HH:mm");
|
||||
formatter = DateTimeFormat.forPattern("E HH:mm")
|
||||
.withLocale(Locale.US);
|
||||
LocalDateTime firstStartDateTime = formatter.parseLocalDateTime(start);
|
||||
startTime.dayOfWeek().set(firstStartDateTime.getDayOfWeek());
|
||||
startTime.hourOfDay().set(firstStartDateTime.getHourOfDay());
|
||||
|
||||
Reference in New Issue
Block a user