-6
    String s;
    Format formatter;
    Date date = new Date();

    formatter = new SimpleDateFormat("yyMMdd");
    java.util.Date date1 = ((DateFormat) formatter).parse(birthDate);
    s = formatter.format(date1);

to format a date from yyyy-MM-dd to yyMMdd, but its not working. Please help.

4

1 回答 1

7

尝试这个

    String s;
    DateFormat formatter;        

    formatter = new SimpleDateFormat("yyyy-MM-dd");
    Date date1 = formatter.parse("2013-07-17");
    formatter = new SimpleDateFormat("yyMMdd");
    s = formatter.format(date1);
    System.out.println(s);
于 2013-07-17T10:37:19.580 回答