|
18 | 18 |
|
19 | 19 | import android.content.res.Resources; |
20 | 20 | import android.content.res.XmlResourceParser; |
| 21 | +import android.text.format.DateUtils; |
| 22 | + |
| 23 | +import com.android.internal.util.XmlUtils; |
21 | 24 |
|
22 | | -import libcore.util.ZoneInfoDB; |
23 | 25 | import org.xmlpull.v1.XmlPullParser; |
24 | 26 | import org.xmlpull.v1.XmlPullParserException; |
25 | 27 |
|
|
28 | 30 | import java.util.ArrayList; |
29 | 31 | import java.util.Calendar; |
30 | 32 | import java.util.Collection; |
31 | | -import java.util.TimeZone; |
32 | 33 | import java.util.Date; |
| 34 | +import java.util.TimeZone; |
33 | 35 |
|
34 | | -import com.android.internal.util.XmlUtils; |
| 36 | +import libcore.util.ZoneInfoDB; |
35 | 37 |
|
36 | 38 | /** |
37 | 39 | * A class containing utility methods related to time zones. |
@@ -245,6 +247,8 @@ public static String getTimeZoneDatabaseVersion() { |
245 | 247 | private static final Object sFormatSync = new Object(); |
246 | 248 | private static char[] sFormatStr = new char[HUNDRED_DAY_FIELD_LEN+5]; |
247 | 249 |
|
| 250 | + private static final long LARGEST_DURATION = (1000 * DateUtils.DAY_IN_MILLIS) - 1; |
| 251 | + |
248 | 252 | static private int accumField(int amt, int suffix, boolean always, int zeropad) { |
249 | 253 | if (amt > 99 || (always && zeropad >= 3)) { |
250 | 254 | return 3+suffix; |
@@ -307,6 +311,10 @@ private static int formatDurationLocked(long duration, int fieldLen) { |
307 | 311 | duration = -duration; |
308 | 312 | } |
309 | 313 |
|
| 314 | + if (duration > LARGEST_DURATION) { |
| 315 | + duration = LARGEST_DURATION; |
| 316 | + } |
| 317 | + |
310 | 318 | int millis = (int)(duration%1000); |
311 | 319 | int seconds = (int) Math.floor(duration / 1000); |
312 | 320 | int days = 0, hours = 0, minutes = 0; |
|
0 commit comments