I want to read a date in the format YYYY-MM-DD.
But if I enter date say for example 2008-1-1, I want to read it as 2008-01-01.
Can anybody help me? Thanks
import java.text.*;
public class Test
{
public static void main(String args[])
{
try
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-DD");
System.out.println(sdf.parse(args[0]).toString());
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
This works OK, no matter if you write as argument "2008-1-1" or "2008-01-01".