Changeset 374 in josm for trunk/src/org
- Timestamp:
- 2007-10-13T00:49:54+02:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/DateParser.java
r298 r374 3 3 4 4 import java.text.ParseException; 5 import java.text.SimpleDateFormat;6 5 import java.util.Date; 7 import java.util.regex.Matcher; 8 import java.util.regex.Pattern; 6 9 7 10 8 /** … … 14 12 */ 15 13 public class DateParser { 16 17 private static final String[] formats = {18 "yyyy-MM-dd'T'HH:mm:ss'Z'",19 "yyyy-MM-dd'T'HH:mm:ssZ",20 "yyyy-MM-dd'T'HH:mm:ss",21 "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",22 "yyyy-MM-dd'T'HH:mm:ss.SSSZ",23 "yyyy-MM-dd HH:mm:ss",24 "MM/dd/yyyy HH:mm:ss",25 "MM/dd/yyyy'T'HH:mm:ss.SSS'Z'",26 "MM/dd/yyyy'T'HH:mm:ss.SSSZ",27 "MM/dd/yyyy'T'HH:mm:ss.SSS",28 "MM/dd/yyyy'T'HH:mm:ssZ",29 "MM/dd/yyyy'T'HH:mm:ss",30 "yyyy:MM:dd HH:mm:ss", // unfcklvble, but I have seen this...31 };32 33 14 public static Date parse(String d) throws ParseException { 34 // first try to fix ruby's broken xmlschema - format 35 Matcher m = Pattern.compile("(....-..-..T..:..:..[+-]..):(..)").matcher(d); 36 if (m.matches()) 37 d = m.group(1) + m.group(2); 38 39 for (String parse : formats) { 40 SimpleDateFormat sdf = new SimpleDateFormat(parse); 41 try {return sdf.parse(d);} catch (ParseException pe) {} 42 } 43 throw new ParseException("", 0); 15 return new PrimaryDateParser().parse(d); 44 16 } 45 17 }
Note:
See TracChangeset
for help on using the changeset viewer.