Code example for TimeZone

Methods: getOffset

0
				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());
						db = openOrCreateDatabase(DATABASE_NAME, SQLiteDatabase.OPEN_READWRITE, null);
						db.execSQL(queryBuf.toString());
					}