SimpleDateFormat bartDateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss"); 
改成:
SimpleDateFormat bartDateFormat = 
new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss",Locale.ENGLISH);

解决方案 »

  1.   

    import java.text.SimpleDateFormat; 
    import java.util.Date; 
    import java.util.Locale
    import java.text.DateFormat;
    import java.text.ParseException;public class DateExample { public static void main(String[] args) { 
    // Create a date formatter that can parse dates of 
    // the form MM-dd-yyyy. 
    SimpleDateFormat bartDateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss",Locale.ENGLISH); // Create a string containing a text date to be parsed. 
    String dateStringToParse = "2004-11-6 23:14:31"; try { 
    // Parse the text version of the date. 
    // We have to perform the parse method in a 
    // try-catch construct in case dateStringToParse 
    // does not contain a date in the format we are expecting. 
    Date date = bartDateFormat.parse(dateStringToParse); // Now send the parsed date as a long value 
    // to the system output. 
    System.out.println(date.getTime()); 

    catch (Exception ex) { 
    System.out.println(ex.getMessage()); 

    } -------------------------------------------
    编译通过,执行出错,返回
    Unparseable date: "2004-11-6 23:14:31"
      

  2.   

    把这一句
    SimpleDateFormat bartDateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss",Locale.ENGLISH); 
    改成:
            SimpleDateFormat bartDateFormat = new SimpleDateFormat(
                "yyyy-MM-dd HH:mm:ss", Locale.ENGLISH);
    就行了。只要你指定的格式和dateStringToParse 里的格式对应就可以转换了
      

  3.   

    那么如果我现在需要将 String dateStringToParse = "2004-11-6 23:14:31"; 格式的 dateStringToParse 转换成(EEE, d MMM yyyy HH:mm:ss",Locale.ENGLISH);的形式这么办呢?
      

  4.   

    用两次SimpleDateFormat撒,一次解析,一次再格式化