Code example for GregorianCalendar

Methods: getTimeaddgetTimeZone

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,LATITUDE,LONGITUDE,ALTITUDE,ACCURACY,SPEED,BEARING) VALUES (" + 
								"'"+timestampFormat.format(greg.getTime())+"',"+
								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());
Stop searching for code, let great code find you!  Add Codota to your java IDE