Ignore:
Timestamp:
2016-01-10T13:04:06+01:00 (5 years ago)
Author:
simon04
Message:

Deprecate PrimaryDateParser in favour of DateUtils

Location:
trunk/src/org/openstreetmap/josm/tools/date
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java

    r9059 r9383  
    4545     * with the timezone lookup, is very expensive.
    4646     */
    47     private static GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
     47    private static final GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
     48    private static final GregorianCalendar calendarLocale = new GregorianCalendar(TimeZone.getDefault());
    4849    private static final DatatypeFactory XML_DATE;
    4950
    5051    static {
    5152        calendar.setTimeInMillis(0);
     53        calendarLocale.setTimeInMillis(0);
    5254
    5355        DatatypeFactory fact = null;
     
    7880        if (checkLayout(str, "xxxx-xx-xxTxx:xx:xxZ") ||
    7981                checkLayout(str, "xxxx-xx-xxTxx:xx:xx") ||
     82                checkLayout(str, "xxxx:xx:xx xx:xx:xx") ||
    8083                checkLayout(str, "xxxx-xx-xx xx:xx:xx UTC") ||
    8184                checkLayout(str, "xxxx-xx-xxTxx:xx:xx+xx:00") ||
    8285                checkLayout(str, "xxxx-xx-xxTxx:xx:xx-xx:00")) {
    83             calendar.set(
     86            final Calendar c = checkLayout(str, "xxxx:xx:xx xx:xx:xx") ? calendarLocale : calendar; // consider EXIF date in default timezone
     87            c.set(
    8488                parsePart4(str, 0),
    8589                parsePart2(str, 5)-1,
     
    9296                int plusHr = parsePart2(str, 20);
    9397                int mul = str.charAt(19) == '+' ? -3600000 : 3600000;
    94                 return calendar.getTimeInMillis()+plusHr*mul;
     98                return c.getTimeInMillis()+plusHr*mul;
    9599            }
    96100
    97             return calendar.getTimeInMillis();
     101            return c.getTimeInMillis();
    98102        } else if (checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxxZ") ||
    99103                checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxx") ||
     104                checkLayout(str, "xxxx:xx:xx xx:xx:xx.xxx") ||
    100105                checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxx+xx:00") ||
    101106                checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxx-xx:00")) {
    102             calendar.set(
     107            final Calendar c = checkLayout(str, "xxxx:xx:xx xx:xx:xx.xxx") ? calendarLocale : calendar; // consider EXIF date in default timezone
     108            c.set(
    103109                parsePart4(str, 0),
    104110                parsePart2(str, 5)-1,
     
    112118            }
    113119
    114             return calendar.getTimeInMillis() + millis;
     120            return c.getTimeInMillis() + millis;
    115121        } else {
    116122            // example date format "18-AUG-08 13:33:03"
  • trunk/src/org/openstreetmap/josm/tools/date/PrimaryDateParser.java

    r9078 r9383  
    1717 *
    1818 * @author Brett Henderson
     19 * @deprecated Use {@link DateUtils} instead!
    1920 */
     21@Deprecated
    2022public class PrimaryDateParser {
    2123    private DatatypeFactory datatypeFactory;
Note: See TracChangeset for help on using the changeset viewer.