Konvertering fra
Timestamp til String
Timestamp tid_timestamp;
String tid_string;
tid_string = tid_timestamp.toString().substring(0,19);
Der 'klippes' her ved 19 så der ikke medtages decimaler på sekunder
tid_string indeholder nu datoen på
formatet: aaaa-mm-dd hh:mm:ss
Konvertering fra String til Timestamp
Timestamp tid_timestamp;
String tid_string;
tid_timestamp = Timestamp.valueOf(tid_string);
tid_string skal indeholde datoen på
formatet: aaaa-mm-dd hh:mm:ss
Kopi af Timestamp (ofte
nødvendig, da attribut skal være nyt objekt)
Timestamp gl_timestamp;
Timestamp ny_timestamp;
ny_timestamp = (Timestamp)gl_timestamp.clone();
Systemdatoen til
Timestamp
import
java.sql.Timestamp;
Timestamp
systemdato = new Timestamp(System.currentTimeMillis());