Last change
on this file since 105 was 105, checked in by imi, 18 years ago |
- fixed the tooltip and shortkey for Selection mapmod
- fixed timestamp import in tagged images (should be ISO-conform now)
|
File size:
886 bytes
|
Line | |
---|
1 | package org.openstreetmap.josm.tools;
|
---|
2 |
|
---|
3 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
4 |
|
---|
5 | import java.text.ParseException;
|
---|
6 | import java.text.SimpleDateFormat;
|
---|
7 | import java.util.Date;
|
---|
8 |
|
---|
9 | /**
|
---|
10 | * Tries to parse a date as good as it can.
|
---|
11 | *
|
---|
12 | * @author Immanuel.Scholz
|
---|
13 | */
|
---|
14 | public class DateParser {
|
---|
15 |
|
---|
16 | private static final String[] formats = {
|
---|
17 | "yyyy-MM-dd'T'HH:mm:ssZ",
|
---|
18 | "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
|
---|
19 | "yyyy-MM-dd HH:mm:ss",
|
---|
20 | "MM/dd/yyyy HH:mm:ss",
|
---|
21 | "MM/dd/yyyy'T'HH:mm:ss.SSSZ",
|
---|
22 | "MM/dd/yyyy'T'HH:mm:ss.SSS",
|
---|
23 | "MM/dd/yyyy'T'HH:mm:ssZ",
|
---|
24 | "MM/dd/yyyy'T'HH:mm:ss",
|
---|
25 | };
|
---|
26 |
|
---|
27 | public static Date parse(String d) throws ParseException {
|
---|
28 | for (String parse : formats) {
|
---|
29 | SimpleDateFormat sdf = new SimpleDateFormat(parse);
|
---|
30 | try {return sdf.parse(d);} catch (ParseException pe) {}
|
---|
31 | }
|
---|
32 | throw new ParseException(tr("No applicable parse format"), 0);
|
---|
33 | }
|
---|
34 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.