I got simple code, maybe the problem relies on the given format string or on the timezone. So here is the code:
public static void main(String[] args) {
SimpleDateFormat df = new SimpleDateFormat("HH:mm");
try {
Date added = df.parse("00:00");
System.out.println(added);
System.out.println(added.getTime());
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
The result is:Thu Jan 01 00:00:00 EET 1970
-10800000 –> should be 0 as we give 00:00 hours in and the other time elements remain default.
//Edit
Yes the problem is with timezone to fix this use
df.setTimeZone(TimeZone.getTimeZone(“UTC”)); before parsing.
The value 10800000 is exactly 3 hours (in milliseconds), which I’m gathering is roughly the offset between EET and UTC (actually, it’s only 2 hours according to this, but I guess the extra hour’s down to DST or something).
Therefore, the difference is probably due to your timezone.