I store dates as int's, and present them as follows;
private DateFormat dfOut = new SimpleDateFormat("dd-MM-yyyy");
private DateFormat dfIn = new SimpleDateFormat("dd-MM-yyyy");
public String format(int time) {
if ( time == -1 ) return "nvt";
synchronized (dfOut) {
long timeL = 1000 * (long)time;
return dfOut.format(new Date( timeL ) );
}
}
public Date parse(String dateStr) {
dfIn.setLenient( false );
if (dateStr == null) return null;
Date result = null;
try {
synchronized (dfIn) {
result = dfIn.parse(dateStr);
}
} catch (ParseException pe) {
return null;
}
return result;
}
This works also for dates before 1970;
Paul