1 import java.text.DateFormat; 2 import java.text.ParseException; 3 import java.text.SimpleDateFormat; 4 5 6 //String--->Date 7 String str1 = "2011-5-31 14:40:50"; 8 DateFormat df = DateFormat.getDateInstance(); 9 Date date; 10 try { 11 date = df.parse(str1); 12 } catch (ParseException e) { 13 e.printStackTrace(); 14 } 15 16 //Date--->String 17 DateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd E"); 18 String str2 = sdf1.format(date));