Dates from Strings in RFC822 format

Discussion in 'Java' started by Darren Davison, Jul 23, 2003.

  1. what's the simplest way to instantiate a java.util.Date given a
    java.lang.String in RFC822 format?


    String d = "Wed, 23 Jul 2003 19:51:20 GMT";

    Date date = [ new Date() based on above String]

    I know I could parse it manually but it seems kludgy - I'd have expected
    some inbuilt method in the java.[util|text].* hierarchy somewhere since
    it's such an old and well used date format. Scanning the javadocs for
    Date, DateFormat, Calendar et al didn't offer anything obvious - unless
    I've missed it.

    Darren Davison, Jul 23, 2003
    1. Advertisements

  2. javax.mail.internet.MimeMessage has a getDate method that
    creates a java.util.Date off the rfc 822 Date header. Get a
    kludge from there :)

    Manish Jethani, Jul 23, 2003
    1. Advertisements

  3. Consider SimpleDateFormat.

    Try "EEE, d MMM yyyy HH:mm:ss z". I haven't, so be warned

    Shripathi Kamath, Jul 23, 2003
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.