Results 1 to 2 of 2
  1. #1
    tommy is offline Member
    Join Date
    Jul 2007
    Posts
    41
    Rep Power
    0

    Default problems with Date format

    I want the Date to be in this format
    05-07-2007,
    But I get
    5-7-2007 and I don't want it.

    how can I do that? ( 05-07-2007)

    any suggestions?

  2. #2
    Seemster is offline Member
    Join Date
    Jul 2007
    Posts
    55
    Rep Power
    0

    Default

    Use the SimpleDateFormat class.

    try {
    // Some examples
    DateFormat formatter = new SimpleDateFormat("MM/dd/yy");
    Date date = (Date)formatter.parse("01/29/02");

    formatter = new SimpleDateFormat("dd-MMM-yy");
    date = (Date)formatter.parse("29-Jan-02");

    // Parse a date and time; see also
    // e317 Parsing the Time Using a Custom Format
    formatter = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
    date = (Date)formatter.parse("2002.01.29.08.36.33");

    formatter = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z");
    date = (Date)formatter.parse("Tue, 29 Jan 2002 22:14:02 -0500");
    } catch (ParseException e) {
    }

Similar Threads

  1. Difference between current date and anothe date
    By vijay balusamy in forum New To Java
    Replies: 1
    Last Post: 04-16-2008, 05:15 PM
  2. How to format the date in particular pattern
    By Java Tip in forum java.text
    Replies: 0
    Last Post: 04-04-2008, 03:35 PM
  3. How to format the date in particular pattern
    By JavaBean in forum Java Tip
    Replies: 0
    Last Post: 10-04-2007, 10:28 PM
  4. Date format display in CSV file after exporting
    By latha in forum Advanced Java
    Replies: 0
    Last Post: 08-03-2007, 09:09 AM
  5. Code format
    By Eric in forum XML
    Replies: 1
    Last Post: 07-06-2007, 08:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •