android.util.TimeFormatException Java Examples
The following examples show how to use
android.util.TimeFormatException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Time.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void checkChar(String s, int spos, char expected) { char c = s.charAt(spos); if (c != expected) { throw new TimeFormatException(String.format( "Unexpected character 0x%02d at pos=%d. Expected 0x%02d (\'%c\').", (int) c, spos, (int) expected, expected)); } }
Example #2
Source File: Time.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private static int getChar(String s, int spos, int mul) { char c = s.charAt(spos); if (Character.isDigit(c)) { return Character.getNumericValue(c) * mul; } else { throw new TimeFormatException("Parse error at pos=" + spos); } }
Example #3
Source File: EventRecurrence.java From SublimePicker with Apache License 2.0 | 5 votes |
@Override public int parsePart(String value, EventRecurrence er) { if (VALIDATE_UNTIL) { try { // Parse the time to validate it. The result isn't retained. Time until = new Time(); until.parse(value); } catch (TimeFormatException tfe) { throw new InvalidFormatException("Invalid UNTIL value: " + value); } } er.until = value; return PARSED_UNTIL; }
Example #4
Source File: FormatUtil.java From sms-ticket with Apache License 2.0 | 5 votes |
public static Time timeFrom3339(String s3339) { final Time time = new Time(); if (TextUtils.isEmpty(s3339)) { return time; } try { time.parse3339(s3339); } catch (TimeFormatException e) { return time; } time.switchTimezone(Time.getCurrentTimezone()); return time; }
Example #5
Source File: FormatUtil.java From sms-ticket with Apache License 2.0 | 5 votes |
public static Time timeFrom3339(String s3339) { final android.text.format.Time time = new Time(); if (TextUtils.isEmpty(s3339)) { return time; } try { time.parse3339(s3339); } catch (TimeFormatException e) { return time; } time.switchTimezone(android.text.format.Time.getCurrentTimezone()); return time; }
Example #6
Source File: EventRecurrence.java From Android-RecurrencePicker with Apache License 2.0 | 5 votes |
@Override public int parsePart(String value, EventRecurrence er) { if (VALIDATE_UNTIL) { try { // Parse the time to validate it. The result isn't retained. Time until = new Time(); until.parse(value); } catch (TimeFormatException tfe) { throw new InvalidFormatException("Invalid UNTIL value: " + value); } } er.until = value; return PARSED_UNTIL; }
Example #7
Source File: Time.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * Parse a time in the current zone in YYYYMMDDTHHMMSS format. */ private boolean parseInternal(String s) { int len = s.length(); if (len < 8) { throw new TimeFormatException("String is too short: \"" + s + "\" Expected at least 8 characters."); } boolean inUtc = false; // year int n = getChar(s, 0, 1000); n += getChar(s, 1, 100); n += getChar(s, 2, 10); n += getChar(s, 3, 1); year = n; // month n = getChar(s, 4, 10); n += getChar(s, 5, 1); n--; month = n; // day of month n = getChar(s, 6, 10); n += getChar(s, 7, 1); monthDay = n; if (len > 8) { if (len < 15) { throw new TimeFormatException( "String is too short: \"" + s + "\" If there are more than 8 characters there must be at least" + " 15."); } checkChar(s, 8, 'T'); allDay = false; // hour n = getChar(s, 9, 10); n += getChar(s, 10, 1); hour = n; // min n = getChar(s, 11, 10); n += getChar(s, 12, 1); minute = n; // sec n = getChar(s, 13, 10); n += getChar(s, 14, 1); second = n; if (len > 15) { // Z checkChar(s, 15, 'Z'); inUtc = true; } } else { allDay = true; hour = 0; minute = 0; second = 0; } weekDay = 0; yearDay = 0; isDst = -1; gmtoff = 0; return inUtc; }