3 Replies Latest reply: Nov 26, 2007 11:23 PM by 807600 RSS

    Converting String to Date format

    807600
      I need to parse my date which is in the format
      yy-MM-dd to the format dd-mon-yy please help me with a code snippet.
        • 1. Re: Converting String to Date format
          807600
          you can use SimpleDateFormatter. Look up the API or Go to javaalmanac.com and search for code snippets.
          please help me with a code snippet
          Figure it out and post back your reply so others reading will have help later on.

          HTH

          cheers..
          • 2. Re: Converting String to Date format
            807600
            i have looked up the API but i'm getting errors; please help with a code snippet
             SimpleDateFormat formatter = new SimpleDateFormat("yy/MM/dd");
                     Date currentTime_1 = new Date();
            //          Date for 13 Nov 2001S
                    // String dateString = "13/11/2001"; 
            //          Parse the string into a Date.
                     Date myDate = formatter.parse(loan_date);
            //          If you want to format the Date -> String output... SimpleDateFormat formatter2 = new SimpleDateFormat("dd-MON-yy");
              String myDateString = formatter.format(myDate);
            //          Result is "Tue, 13 Nov 2001"
            • 3. Re: Converting String to Date format
              807600
              alright bud. Dont have a snippet ready.
              Here are the 2 links which have what you want. figure out and post back what you did.

              http://forum.java.sun.com/thread.jspa?threadID=598820&messageID=3190547
              http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20946815.html

              hth