I am having TimeStamp as a String input. I'll have to convert it into a String of another format.
For example:
input string : 2013-12-23 20:59:15.0
output string: 2013/12/23
So I wrote a small Java program to do that :
public class test {
public static void main(String[] args) throws ParseException
{
DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss.SS");
String x ="2013-12-23 20:59:15.0";
Date parsedDate = dateFormat.parse(x);
Format formatter = new SimpleDateFormat("yyyy/MM/dd");
String y = formatter.format(parsedDate);
System.out.println(y);
}
}
Now no matter what the input is, the month value always comes back to be 1
.
For example :
input string : 2013-12-23 20:59:15.0
output string: 2013/01/23
Another example :
input string : 2012-05-23 20:59:15.0
output string: 2012/01/23
Am I missing something here ?