aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Albert <aalbert@google.com>2011-08-07 13:19:46 +0300
committerAlon Albert <aalbert@google.com>2011-08-07 13:19:46 +0300
commit341231a27ba891e90ded672e54817ff011317931 (patch)
treef86d1fb5fa4f3784e14698bf5bbe1b05a31464cd
parent0304a16e191a2e2af8289c6e7e1ad9734a0dc06d (diff)
downloadcalendar-341231a27ba891e90ded672e54817ff011317931.tar.gz
catch exception from time.parse() and throw an exception we handle better
Bug: 3415450 Change-Id: I0a83082b5de6d5c243ea84134769516e39e5a5fd
-rw-r--r--src/com/android/calendarcommon/RecurrenceSet.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/com/android/calendarcommon/RecurrenceSet.java b/src/com/android/calendarcommon/RecurrenceSet.java
index 426238f..3b91a1d 100644
--- a/src/com/android/calendarcommon/RecurrenceSet.java
+++ b/src/com/android/calendarcommon/RecurrenceSet.java
@@ -22,6 +22,7 @@ import android.provider.CalendarContract;
import android.text.TextUtils;
import android.text.format.Time;
import android.util.Log;
+import android.util.TimeFormatException;
import java.util.List;
import java.util.regex.Pattern;
@@ -134,7 +135,8 @@ public class RecurrenceSet {
* @param recurrence The recurrence to be parsed.
* @return The list of date/times.
*/
- public static long[] parseRecurrenceDates(String recurrence) {
+ public static long[] parseRecurrenceDates(String recurrence)
+ throws EventRecurrence.InvalidFormatException{
// TODO: use "local" time as the default. will need to handle times
// that end in "z" (UTC time) explicitly at that point.
String tz = Time.TIMEZONE_UTC;
@@ -149,7 +151,14 @@ public class RecurrenceSet {
long[] dates = new long[n];
for (int i = 0; i<n; ++i) {
// The timezone is updated to UTC if the time string specified 'Z'.
- time.parse(rawDates[i]);
+ try {
+ time.parse(rawDates[i]);
+ } catch (TimeFormatException e) {
+ throw new EventRecurrence.InvalidFormatException(
+ "TimeFormatException thrown when parsing time " + rawDates[i]
+ + " in recurrence " + recurrence);
+
+ }
dates[i] = time.toMillis(false /* use isDst */);
time.timezone = tz;
}