High , Friend this is small but irritating program when u can't manage it properly.U can create date object of any date in any input format changing the SipleDateFormat constructor parameter.
//Program code...
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateParse {
public static void main(String ars[])
{
DateParse dp=new DateParse();
Date mm=dp.paseDate("22-2-1988");
System.out.println("date="+mm.toString());
}
public Date paseDate(String dateParam)
{
Date tt=new Date();
SimpleDateFormat smdf=new SimpleDateFormat("dd-MM-yyyy");
System.out.println("");
try
{
tt=smdf.parse(dateParam);
}catch(Exception e)
{
e.printStackTrace();
}
return tt;
}
}
No comments:
Post a Comment