Inspite of using substring.You can use SimpleDateFormat class which provide
you the facility of format date to any any Date Format .For Your refrence
sending code which is generic one and convert any DateFormat-

How to convert date from "2002-11-29" to "29/11/2002" (Or from any format to
any format.
they can be passed as params.)


public static String convertDate(String date, String fromPattern, String
toPattern) {
    String newFormat = null;
    try {
        SimpleDateFormat fmt = new SimpleDateFormat(fromPattern);
        Date objDt = fmt.parse(date);
        fmt.applyPattern(toPattern);
        newFormat = fmt.format(objDt);
    }catch(ParseException pe)   {}
    return newFormat;
}


String newFormat = convertDate("2002-11-29", "yyyy-MM-dd", "dd/MM/yyyy");
System.out.println(newFormat);    //will print 29/11/2002

Regard
Ripudaman Sharma
Analyst
Indus Software




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to