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?

    i.e.

    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.

    tia,

    --
    darren@ public key
    davison|uk.net www.davison.uk.net/key.jsp
     
    Darren Davison, Jul 23, 2003
    #1
    1. Advertising

  2. Darren Davison wrote:

    > what's the simplest way to instantiate a java.util.Date given a
    > java.lang.String in RFC822 format?
    >
    > i.e.
    >
    > String d = "Wed, 23 Jul 2003 19:51:20 GMT";
    >
    > Date date = [ new Date() based on above String]


    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

    --
    Manish Jethani (manish.j at gmx.net)
    phone (work) +91-80-51073488
     
    Manish Jethani, Jul 23, 2003
    #2
    1. Advertising

  3. "Darren Davison" <> wrote in message
    news:3f1edb3f$0$196$...
    > what's the simplest way to instantiate a java.util.Date given a
    > java.lang.String in RFC822 format?
    >
    > i.e.
    >
    > 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.
    >
    > tia,
    >


    Consider SimpleDateFormat.

    http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html

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

    HTH,

    --
    Shripathi Kamath
    NETAPHOR SOFTWARE INC.
    http://www.netaphor.com
     
    Shripathi Kamath, Jul 23, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vladimir Litovka

    rfc822 regexp

    Vladimir Litovka, Feb 4, 2004, in forum: Perl
    Replies:
    1
    Views:
    791
  2. David Lozzi

    Dates dates dates dates... SQL and ASP.NET

    David Lozzi, Sep 29, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    870
    Rob Schieber
    Sep 30, 2005
  3. Rico

    JavaMail - RFC822

    Rico, Dec 23, 2004, in forum: Java
    Replies:
    4
    Views:
    1,468
  4. Malcolm Dew-Jones

    Q: xml for rfc822/mime

    Malcolm Dew-Jones, May 5, 2004, in forum: XML
    Replies:
    1
    Views:
    498
    Johannes Koch
    May 5, 2004
  5. PW

    Dates! Dates! Dates!

    PW, Aug 7, 2004, in forum: ASP General
    Replies:
    4
    Views:
    199
    Mark Schupp
    Aug 9, 2004
Loading...

Share This Page