I\'ve been searching all over and just can\'t find a explanation or reason why this is happening but the parse(String) method of DateFormat just isn\'t parsing my String cor
The result format is the default format of Date#toString() (click link to see the javadoc). You're apparently doing a System.out.println(date)
. You would like to use SimpleDateFormat#format() instead with another pattern to format it in the desired format. E.g.
String newDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
Update: You shouldn't care about the format when using Date
. You should only care about the format at that point when Date
is to be converted (displayed) as String
. As to the difference in timestamps, the Date
uses millisecond precision for the timestamp while HTTP header uses second precision. You'd like to divide the timestamps by 1000 before comparing.