source: josm/src/org/openstreetmap/josm/tools/DateParser.java@ 106

Last change on this file since 106 was 106, checked in by imi, 18 years ago
  • fixed import from GPX (time not read somtimes)
  • fixed delete mode does not join line segments
  • fixed incomplete segments not occour in segment list (=does not get updated on merge)
  • added josm/ignore will ignore the object on uploads
File size: 987 bytes
Line 
1package org.openstreetmap.josm.tools;
2
3import static org.openstreetmap.josm.tools.I18n.tr;
4
5import java.text.ParseException;
6import java.text.SimpleDateFormat;
7import java.util.Date;
8
9/**
10 * Tries to parse a date as good as it can.
11 *
12 * @author Immanuel.Scholz
13 */
14public class DateParser {
15
16 private static final String[] formats = {
17 "yyyy-MM-dd'T'HH:mm:ss'Z'",
18 "yyyy-MM-dd'T'HH:mm:ssZ",
19 "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
20 "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
21 "yyyy-MM-dd HH:mm:ss",
22 "MM/dd/yyyy HH:mm:ss",
23 "MM/dd/yyyy'T'HH:mm:ss.SSSZ",
24 "MM/dd/yyyy'T'HH:mm:ss.SSS'Z'",
25 "MM/dd/yyyy'T'HH:mm:ss.SSS",
26 "MM/dd/yyyy'T'HH:mm:ssZ",
27 "MM/dd/yyyy'T'HH:mm:ss",
28 };
29
30 public static Date parse(String d) throws ParseException {
31 for (String parse : formats) {
32 SimpleDateFormat sdf = new SimpleDateFormat(parse);
33 try {return sdf.parse(d);} catch (ParseException pe) {}
34 }
35 throw new ParseException(tr("No applicable parse format"), 0);
36 }
37}
Note: See TracBrowser for help on using the repository browser.