private Date parseDate() throws ParseException { String timestamp = getAttribute("timestamp"); if(timestamp == null) return null; return dateFormat.parse(timestamp); }
public Date parse(String source) throws ParseException { // optional: parse milliseconds if(hasMillis(source)) { return MILLIS.parse(source); } return super.parse(source); }
private ChangesetNote parseChangesetComment() throws ParseException { ChangesetNote comment = new ChangesetNote(); comment.user = parseUser(); comment.date = dateFormat.parse(getAttribute("date")); return comment; }
public void testByClosedAfter() throws ParseException { QueryChangesetsFilters filters = new QueryChangesetsFilters(); Date validDate = dateFormat.parse("2222-11-22T22:11:00+0700"); filters.byClosedAfter(validDate); assertEquals(validDate, dateFormat.parse(getParam(filters.toParamString(), "time"))); }
user.createdDate = dateFormat.parse(getAttribute("account_created"));
@Override protected void onStartElement() throws ParseException { if(getName().equals(GPX_FILE)) { trace = new GpsTraceDetails(); trace.id = getLongAttribute("id"); trace.visibility = GpsTraceDetails.Visibility.valueOf(getAttribute("visibility").toUpperCase(Locale.UK)); trace.name = getAttribute("name"); trace.userName = getAttribute("user"); Boolean pendingAttribute = getBooleanAttribute("pending"); trace.pending = pendingAttribute == null || pendingAttribute; String lat = getAttribute("lat"); String lon = getAttribute("lon"); if(lat != null && lon != null) { trace.position = OsmLatLon.parseLatLon(lat, lon); } String timestamp = getAttribute("timestamp"); if(timestamp != null) trace.date = dateFormat.parse(timestamp); } }
private ChangesetInfo parseChangeset() throws ParseException { BoundingBox bounds = null; if(getAttribute("min_lat") != null) { bounds = new BoundingBox(OsmLatLon.parseLatLon(getAttribute("min_lat"), getAttribute("min_lon")), OsmLatLon.parseLatLon(getAttribute("max_lat"), getAttribute("max_lon"))); } String closedAtStr = getAttribute("closed_at"); Date closedAt = null; if(closedAtStr != null) { closedAt = dateFormat.parse(closedAtStr); } User user = parseUser(); // user must be defined for a changeset if(user == null) throw new NullPointerException(); ChangesetInfo result = new ChangesetInfo(); result.id = getLongAttribute("id"); result.date = result.dateCreated = dateFormat.parse(getAttribute("created_at")); result.dateClosed = closedAt; result.user = user; result.boundingBox = bounds; result.isOpen = getBooleanAttribute("open"); result.notesCount = getIntAttribute("comments_count"); return result; }