ich hätte da noch eine frage und zwar habe ich standardmäßig die GMT-Zeit in die Datenbank gespeichert:
jetzt möchte ich aber die GPS-Zeit in die Datenbank hineinspeichern, die aus dem NMEA Stream herausgelesen wird:
wie bringe ich die GPSTime, die nur aus 2 Strings besteht, in das SimpleDateFormat "timestampFormat" (damit auch beim SELECT ein ORDER BY GMTTIMESTAMP ASC möglich ist)?
Java:
private final DateFormat timestampFormat = new SimpleDateFormat("yyyyMMddHHmmss");
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()+","+...
Java:
public void onNmeaReceived(long timestamp, String nmea) {
if (!nmea.startsWith(NMEA_RMC))
return ;
// extract time, date
String[] tokens = nmea.split(",");
String utcTime = tokens[1];
String utcDate = tokens[9];
// parse
DateFormat df = new SimpleDateFormat("HHmmss.S ddMMyy Z");
String GPSTime = utcTime + " " + utcDate + " +0000";
wie bringe ich die GPSTime, die nur aus 2 Strings besteht, in das SimpleDateFormat "timestampFormat" (damit auch beim SELECT ein ORDER BY GMTTIMESTAMP ASC möglich ist)?