Skip to content

Commit ef69f4c

Browse files
committed
Workaround the com.dropbox.core.BadRequestException on devices with locale whose numeric character is non-ascii (dropbox#119)
1 parent ce883f4 commit ef69f4c

File tree

1 file changed

+4
-3
lines changed
  • src/main/java/com/dropbox/core/stone

1 file changed

+4
-3
lines changed

src/main/java/com/dropbox/core/stone/Util.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.text.SimpleDateFormat;
66
import java.util.Date;
77
import java.util.GregorianCalendar;
8+
import java.util.Locale;
89
import java.util.TimeZone;
910

1011
import com.fasterxml.jackson.core.JsonFactory;
@@ -19,7 +20,7 @@ final class Util {
1920
private static final int SHORT_FORMAT_LENGTH = DATE_FORMAT.replace("'", "").length();
2021

2122
public static String formatTimestamp(Date timestamp) {
22-
DateFormat format = new SimpleDateFormat(DATE_TIME_FORMAT);
23+
DateFormat format = new SimpleDateFormat(DATE_TIME_FORMAT, Locale.ENGLISH);
2324
format.setCalendar(new GregorianCalendar(UTC));
2425
return format.format(timestamp);
2526
}
@@ -29,9 +30,9 @@ public static Date parseTimestamp(String timestamp) throws ParseException {
2930

3031
DateFormat format = null;
3132
if (length == LONG_FORMAT_LENGTH) {
32-
format = new SimpleDateFormat(DATE_TIME_FORMAT);
33+
format = new SimpleDateFormat(DATE_TIME_FORMAT, Locale.ENGLISH);
3334
} else if (length == SHORT_FORMAT_LENGTH) {
34-
format = new SimpleDateFormat(DATE_FORMAT);
35+
format = new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH);
3536
} else {
3637
throw new ParseException("timestamp has unexpected format: '" + timestamp + "'", 0);
3738
}

0 commit comments

Comments
 (0)