summaryrefslogtreecommitdiffstats
path: root/emailcommon
diff options
context:
space:
mode:
authorJay Shrauner <shrauner@google.com>2014-05-02 16:17:17 -0700
committerJay Shrauner <shrauner@google.com>2014-05-02 16:17:17 -0700
commit2fc13087e700ee044684adb99e7114c9f477c67f (patch)
tree0e81035407393b229512f0d8c1e47ca02011b276 /emailcommon
parentf21e6a8983f2ff9eb8bcff2612c2fefd1076f554 (diff)
downloadandroid_packages_apps_Email-2fc13087e700ee044684adb99e7114c9f477c67f.tar.gz
android_packages_apps_Email-2fc13087e700ee044684adb99e7114c9f477c67f.tar.bz2
android_packages_apps_Email-2fc13087e700ee044684adb99e7114c9f477c67f.zip
Parse abbreviated date fields
Add support for abbreviated dates with no timestamp (eg, "2009-01-02") to parseEmailDateTimeToMillis. Bug:14496986 Change-Id: Ifc77cb75fd9e23536b48c8f6ecefc0e2e8f1cc2c
Diffstat (limited to 'emailcommon')
-rw-r--r--emailcommon/src/com/android/emailcommon/utility/Utility.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/emailcommon/src/com/android/emailcommon/utility/Utility.java b/emailcommon/src/com/android/emailcommon/utility/Utility.java
index 6ef1d8421..592d03c15 100644
--- a/emailcommon/src/com/android/emailcommon/utility/Utility.java
+++ b/emailcommon/src/com/android/emailcommon/utility/Utility.java
@@ -263,6 +263,9 @@ public class Utility {
return cal;
}
+ private static final ThreadLocalDateFormat mAbbrevEmailDateTimeFormat =
+ new ThreadLocalDateFormat("yyyy-MM-dd");
+
private static final ThreadLocalDateFormat mEmailDateTimeFormat =
new ThreadLocalDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
@@ -277,7 +280,9 @@ public class Utility {
@VisibleForTesting
public static long parseEmailDateTimeToMillis(String date) throws ParseException {
final GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
- if (date.length() <= 20) {
+ if (date.length() <= 10) {
+ cal.setTime(mAbbrevEmailDateTimeFormat.parse(date));
+ } else if (date.length() <= 20) {
cal.setTime(mEmailDateTimeFormat.parse(date));
} else {
cal.setTime(mEmailDateTimeFormatWithMillis.parse(date));