Reputation: 57
I'm using Apache Client to send HTTP/1.0 request and receive the response in java.
Now I met the problem: the header of response contains the property, "Date" which could be those three formats:
Sun, 06 Nov 1994 08:49:37 GMT
// RFC 822, updated by RFC 1123Sunday, 06-Nov-94 08:49:37 GMT
// RFC 850, obsoleted by RFC 1036Sun Nov 6 08:49:37 1994
// ANSI C's asctime() formatMy problem is that I can use SimpleDateFormat
to parse one type of those three formats but I can not find a good solution to parse ANY/ALL of those three formats.
(But HTTP/1.0 protocol requires to support all those formats, I can only support one of them)
Thanks indeed
Upvotes: 0
Views: 1306
Reputation: 1688
If you can't put the time in milliseconds into the date field of the header of the server response (which is not conform to the http specification), then i think the only way is the following:
create three formats then parse the date value with every format and return or work with the value that didn't throw a parse exception.
Hope it helps.
Upvotes: 2