- Timestamp:
- 2015-04-18T22:44:31+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java
r8224 r8225 10 10 import java.awt.event.MouseAdapter; 11 11 import java.awt.event.MouseEvent; 12 import java.text. SimpleDateFormat;12 import java.text.DateFormat; 13 13 import java.util.ArrayList; 14 14 import java.util.Arrays; … … 46 46 import org.openstreetmap.josm.gui.layer.NoteLayer; 47 47 import org.openstreetmap.josm.tools.ImageProvider; 48 import org.openstreetmap.josm.tools.date.DateUtils; 48 49 49 50 /** … … 229 230 230 231 private DefaultListCellRenderer defaultListCellRenderer = new DefaultListCellRenderer(); 231 private final SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy kk:mm");232 private final DateFormat dateFormat = DateUtils.getDateTimeFormat(DateFormat.MEDIUM, DateFormat.SHORT); 232 233 233 234 @Override … … 241 242 userName = "<Anonymous>"; 242 243 } 243 String toolTipText = userName + " @ " + sdf.format(note.getCreatedAt());244 String toolTipText = userName + " @ " + dateFormat.format(note.getCreatedAt()); 244 245 JLabel jlabel = (JLabel)comp; 245 246 jlabel.setText(note.getId() + ": " +text); -
trunk/src/org/openstreetmap/josm/io/NoteReader.java
r8224 r8225 6 6 import java.io.InputStream; 7 7 import java.nio.charset.StandardCharsets; 8 import java.text.ParseException;9 import java.text.SimpleDateFormat;10 8 import java.util.ArrayList; 11 9 import java.util.Date; 12 10 import java.util.List; 13 import java.util.Locale;14 11 15 12 import javax.xml.parsers.ParserConfigurationException; … … 22 19 import org.openstreetmap.josm.data.notes.NoteComment.Action; 23 20 import org.openstreetmap.josm.data.osm.User; 21 import org.openstreetmap.josm.tools.date.DateUtils; 24 22 import org.xml.sax.Attributes; 25 23 import org.xml.sax.InputSource; … … 49 47 */ 50 48 private class Parser extends DefaultHandler { 51 52 private final SimpleDateFormat ISO8601_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX", Locale.ENGLISH);53 private final SimpleDateFormat NOTE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z", Locale.ENGLISH);54 49 55 50 private NoteParseMode parseMode; … … 106 101 } else { 107 102 thisNote.setState(Note.State.closed); 108 thisNote.setClosedAt( parseDate(ISO8601_FORMAT,closedTimeStr));109 } 110 thisNote.setCreatedAt( parseDate(ISO8601_FORMAT,attrs.getValue("created_at")));103 thisNote.setClosedAt(DateUtils.fromString(closedTimeStr)); 104 } 105 thisNote.setCreatedAt(DateUtils.fromString(attrs.getValue("created_at"))); 111 106 break; 112 107 case "comment": … … 119 114 commentUsername = attrs.getValue("user"); 120 115 noteAction = Action.valueOf(attrs.getValue("action")); 121 commentCreateDate = parseDate(ISO8601_FORMAT,attrs.getValue("timestamp"));116 commentCreateDate = DateUtils.fromString(attrs.getValue("timestamp")); 122 117 String isNew = attrs.getValue("is_new"); 123 118 if(isNew == null) { … … 166 161 break; 167 162 case "date_created": 168 thisNote.setCreatedAt( parseDate(NOTE_DATE_FORMAT,buffer.toString()));163 thisNote.setCreatedAt(DateUtils.fromString(buffer.toString())); 169 164 break; 170 165 case "date_closed": 171 thisNote.setClosedAt( parseDate(NOTE_DATE_FORMAT,buffer.toString()));166 thisNote.setClosedAt(DateUtils.fromString(buffer.toString())); 172 167 break; 173 168 case "date": 174 commentCreateDate = parseDate(NOTE_DATE_FORMAT,buffer.toString());169 commentCreateDate = DateUtils.fromString(buffer.toString()); 175 170 break; 176 171 case "user": … … 196 191 public void endDocument() throws SAXException { 197 192 parsedNotes = notes; 198 }199 200 /**201 * Convenience method to handle the date parsing try/catch. Will return null if202 * there is a parsing exception. This means whatever generated this XML is in error203 * and there isn't anything we can do about it.204 * @param dateStr - String to parse205 * @return Parsed date, null if parsing fails206 */207 private Date parseDate(SimpleDateFormat sdf, String dateStr) {208 try {209 return sdf.parse(dateStr);210 } catch(ParseException e) {211 Main.error(e);212 return null;213 }214 193 } 215 194 } -
trunk/src/org/openstreetmap/josm/io/NoteWriter.java
r7937 r8225 7 7 import java.io.PrintWriter; 8 8 import java.nio.charset.StandardCharsets; 9 import java.text.SimpleDateFormat; 10 import java.util.Locale; 9 import java.text.DateFormat; 11 10 12 11 import org.openstreetmap.josm.data.notes.Note; … … 14 13 import org.openstreetmap.josm.data.osm.NoteData; 15 14 import org.openstreetmap.josm.data.osm.User; 15 import org.openstreetmap.josm.tools.date.DateUtils; 16 16 17 17 /** … … 23 23 public class NoteWriter extends XmlWriter { 24 24 25 private final SimpleDateFormat ISO8601_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX", Locale.ENGLISH);25 private final DateFormat ISO8601_FORMAT = DateUtils.newIsoDateTimeFormat(); 26 26 27 27 /**
Note:
See TracChangeset
for help on using the changeset viewer.