I want to format a from string date to another String date value. The date is show as "03/20/2014". I have to format it to "2014-03-20". Could you please give me sample codeing for this?
Thanks
I want to format a from string date to another String date value. The date is show as "03/20/2014". I have to format it to "2014-03-20". Could you please give me sample codeing for this?
Thanks
import java.text.SimpleDateFormat;
import java.util.Date;
class sample
{
public static void main(String[] args) throws Exception
{
String source= new String("03/20/2014");
SimpleDateFormat sdfinput = new SimpleDateFormat("MM/dd/yyyy");
SimpleDateFormat sdfoutput = new SimpleDateFormat("yyyy-MM-dd");
Date inputdate=sdfinput.parse(source);
String outputDate=sdfoutput.format(inputdate);
System.out.println(outputDate);
}
}