[Solved] How to parse date format in java? [duplicate]


Try this..

String s1 = "2013-01-15 8:00:03";
    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd h:mm:ss");
    try {
        Date dt=sdf.parse(s1);//converting to date
         SimpleDateFormat sdf1=new SimpleDateFormat("dd-MMM-yyyy h:mm:ss");
         String s2=sdf1.format(dt);//formating to new format string
         System.out.println(s2);
    } catch (ParseException ex) {

    }

//new answer

public class Dd {

    public static void main(String args[]) throws ParseException {

        String s1 = "2014-01-15 00:003:00";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        try {
            Date date = sdf.parse(s1);
            SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MMM-yyyy hh:mm:ss");
            String s3 = sdf1.format(date);
            System.out.println(s3);

        } catch (ParseException e) {
            System.out.println(e);
        }

    }
}

10

solved How to parse date format in java? [duplicate]