Results 1 to 2 of 2
  1. #1
    ztomtomz is offline Member
    Join Date
    Nov 2012
    Posts
    5
    Rep Power
    0

    Default Formatting date and returning as a string.

    public String getDateAsString()
    {
    // Returns the date as a sting formatted as dd/mm/yy
    SimpleDateFormat formatDate = new SimpleDateFormat("DD/MM/yyyy");

    return formatDate.format(startDate);
    }


    I've gone through loads of tutorials but i just cant seem to find an answer at all. My problem is that i need to format my date field and then return it as a string so it can be accessed by another method. Everywhere seems to only give tutorials and explanations towards formatting and changing it with another string but i dont want to use a pre-set string.

  2. #2
    eRaaaa is online now Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default Re: Formatting date and returning as a string.

    ?? startDate is from the type Date or? So the method will do what you want? I don`t understand the problem....

Similar Threads

  1. converting string (GMT date) to date in US time.
    By JRuyechan in forum New To Java
    Replies: 1
    Last Post: 10-15-2010, 07:07 AM
  2. A problem with date formatting
    By indra-uolles in forum New To Java
    Replies: 5
    Last Post: 08-02-2010, 08:08 PM
  3. Date formatting
    By bikkerss in forum New To Java
    Replies: 13
    Last Post: 05-08-2010, 04:07 PM
  4. Formatting time and date
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 07:35 PM
  5. Formatting the date
    By yuchuang in forum New To Java
    Replies: 5
    Last Post: 05-07-2007, 06:08 PM

Posting Permissions

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