fix SimpleDateFormat to not be locale dependent

This commit is contained in:
Grahame Grieve 2019-12-19 22:39:46 +11:00
parent 47a1382966
commit 6e0df466f7
4 changed files with 7 additions and 4 deletions

View File

@ -2925,7 +2925,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
} catch (ParseException e) {
return ds;
}
return new SimpleDateFormat("dd-MMM yyyy").format(date);
return new SimpleDateFormat("dd-MMM yyyy", new Locale("en", "US")).format(date);
}
private String describeModule(String module) {

View File

@ -68,6 +68,7 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.apache.commons.codec.binary.Base64;
@ -498,7 +499,7 @@ public class ClientUtils {
String dateTime = null;
try {
dateTime = serverConnection.getHeaderField("Last-Modified");
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", new Locale("en", "US"));
Date lastModifiedTimestamp = format.parse(dateTime);
Calendar calendar=Calendar.getInstance();
calendar.setTime(lastModifiedTimestamp);

View File

@ -58,6 +58,7 @@ import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
@ -415,7 +416,7 @@ public class ResourceAddress {
}
public static String getCalendarDateInIsoTimeFormat(Calendar calendar) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");//TODO Move out
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss", new Locale("en", "US"));//TODO Move out
format.setTimeZone(TimeZone.getTimeZone("GMT"));
return format.format(calendar.getTime());
}

View File

@ -40,6 +40,7 @@ import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
@ -442,7 +443,7 @@ public class PackageCacheManager {
}
private Date readDate(String s) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM, yyyy HH:mm:ss Z");
SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM, yyyy HH:mm:ss Z", new Locale("en", "US"));
return sdf.parse(s);
}