private Date parseDate() throws ParseException { String timestamp = getAttribute("timestamp"); if(timestamp == null) return null; return dateFormat.parse(timestamp); }
/** * Filter by changesets that have at one time been open during the given time range * * @param closedAfter limit search to changesets that have been closed after this date * @param createdBefore limit search to changesets that have been created before this date */ public QueryChangesetsFilters byOpenSomeTimeBetween(Date createdBefore, Date closedAfter) { params.put("time", dateFormat.format(closedAfter) + "," + dateFormat.format(createdBefore)); return this; }
public Date parse(String source) throws ParseException { // optional: parse milliseconds if(hasMillis(source)) { return MILLIS.parse(source); } return super.parse(source); }
/** * @param closedAfter limit search to changesets that have been closed after this date */ public QueryChangesetsFilters byClosedAfter(Date closedAfter) { params.put("time", dateFormat.format(closedAfter)); return this; }
private ChangesetNote parseChangesetComment() throws ParseException { ChangesetNote comment = new ChangesetNote(); comment.user = parseUser(); comment.date = dateFormat.parse(getAttribute("date")); return comment; }
/** * @param date include notes only created after the given date */ public QueryNotesFilters createdAfter(Date date) { params.put("from", dateFormat.format(date)); return this; }
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"))); }
/** * @param date include notes only created after the given date. If not specified, now */ public QueryNotesFilters createdBefore(Date date) { params.put("to", dateFormat.format(date)); return this; }
public String format(Date date) { if(date.getTime() % 1000 > 0) { return MILLIS.format(date); } return super.format(date); } }
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; }