d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Convert Yy-mm-]]]\ To String
Add Reply New Topic New Poll
Member
Posts: 4,609
Joined: Mar 9 2008
Gold: 2,937.00
Nov 6 2012 05:05pm
I want to convert 05-10-26 to
October 26, 2005
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Nov 6 2012 05:13pm
http://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html

use two of these. parse reads the string, format writes the string
Member
Posts: 4,609
Joined: Mar 9 2008
Gold: 2,937.00
Nov 6 2012 06:21pm
Doesn't help me as I am using that code and it give me what I don't want...The output is VERY SPECIFIC!

Code

         DateFormat formatter = null;
         Date convertedDate = null;

   try{
    String date = "05-10-26";
    formatter = new SimpleDateFormat("yy-MM-dd");
    convertedDate = (Date) formatter.parse(date);
    System.out.println("Date from dd-MM-yyyy String in Java : "
       + convertedDate);
   }
   catch (ParseException e){
    System.err.println(e);}


Gives me
Wed Oct 26 00:00:00 EDT 2005

I want Only what is Above...
Member
Posts: 4,605
Joined: Sep 15 2011
Gold: 9,464.00
Nov 6 2012 06:27pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Nov 6 2012 09:13pm
Quote (NamelessPrince @ Nov 6 2012 08:21pm)
Doesn't help me as I am using that code and it give me what I don't want...The output is VERY SPECIFIC!

Code
DateFormat formatter = null;
         Date convertedDate = null;

   try{
    String date = "05-10-26";
    formatter = new SimpleDateFormat("yy-MM-dd");
    convertedDate = (Date) formatter.parse(date);
    System.out.println("Date from dd-MM-yyyy String in Java : "
       + convertedDate);
   }
   catch (ParseException e){
    System.err.println(e);}


Gives me
Wed Oct 26 00:00:00 EDT 2005

I want Only what is Above...


did you complete ignore what i told you?

Quote
use two of these

I only see one in your code.

Quote
format writes the string


Instead of calling format(..) you decide to call toString().

And then you complain that i couldn't help you.
Member
Posts: 29,614
Joined: Sep 23 2008
Gold: 0.00
Nov 11 2012 05:19am
Quote (NamelessPrince @ Nov 6 2012 06:05pm)
I want to convert 05-10-26 to
October 26, 2005


Parse the input string delimited by "-" and assign strings to each.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll