Fixed error that happened on non-US devices

This commit is contained in:
daniel oeh 2012-06-16 12:46:52 +02:00
parent 8078e34912
commit c41605ef3b
1 changed files with 6 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package de.podfetcher.syndication.util;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Locale;
import android.util.Log; import android.util.Log;
@ -21,11 +22,12 @@ public class SyndDateUtils {
public static Date parseRFC822Date(final String date) { public static Date parseRFC822Date(final String date) {
Date result = null; Date result = null;
SimpleDateFormat format = new SimpleDateFormat(RFC822DAY); SimpleDateFormat format = new SimpleDateFormat(RFC822DAY, Locale.US);
try { try {
result = format.parse(date); result = format.parse(date);
} catch (ParseException e) { } catch (ParseException e) {
format = new SimpleDateFormat(RFC822); e.printStackTrace();
format = new SimpleDateFormat(RFC822, Locale.US);
try { try {
result = format.parse(date); result = format.parse(date);
} catch (ParseException e1) { } catch (ParseException e1) {
@ -40,14 +42,14 @@ public class SyndDateUtils {
Date result = null; Date result = null;
SimpleDateFormat format = null; SimpleDateFormat format = null;
if (date.endsWith("Z")) { if (date.endsWith("Z")) {
format = new SimpleDateFormat(RFC3339UTC); format = new SimpleDateFormat(RFC3339UTC, Locale.US);
try { try {
result = format.parse(date); result = format.parse(date);
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
} else { } else {
format = new SimpleDateFormat(RFC3339LOCAL); format = new SimpleDateFormat(RFC3339LOCAL, Locale.US);
// remove last colon // remove last colon
StringBuffer buf = new StringBuffer(date.length() - 1); StringBuffer buf = new StringBuffer(date.length() - 1);
int colonIdx = date.lastIndexOf(':'); int colonIdx = date.lastIndexOf(':');