Code example for GregorianCalendar

Methods: add, getTime, getTimeZone

0
	    if (loc != null) {
		boolean pointIsRecorded = false;
		try { 
		    if (loc.hasAccuracy() && loc.getAccuracy() <= minAccuracyMeters) {
			pointIsRecorded = true;
			GregorianCalendar greg = new GregorianCalendar();
			TimeZone tz = greg.getTimeZone();
			int offset = tz.getOffset(System.currentTimeMillis());
			greg.add(Calendar.SECOND, (offset/1000) * -1);
			StringBuffer queryBuf = new StringBuffer();
			queryBuf.append("INSERT INTO "+POINTS_TABLE_NAME+
					" (GMTTIMESTAMP,TIMESTAMP,LATITUDE,LONGITUDE,ALTITUDE,ACCURACY,SPEED,BEARING) VALUES (" + 
					"'"+timestampFormat.format(greg.getTime())+"',"+
					+ now +","+
					loc.getLatitude()+","+
					loc.getLongitude()+","+
					(loc.hasAltitude() ? loc.getAltitude() : "NULL")+","+
					(loc.hasAccuracy() ? loc.getAccuracy() : "NULL")+","+
					(loc.hasSpeed() ? loc.getSpeed() : "NULL")+","+
					(loc.hasBearing() ? loc.getBearing() : "NULL")+");");
			Log.i(tag, queryBuf.toString());