使用SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
sdf.parse(strDate);如果成功返回就是正确的string了

解决方案 »

  1.   

    SimpleDateFormat类没有parse方法阿。
      

  2.   

    不可能吧??
    你的是什么jdk??public Date parse(String text,
                      ParsePosition pos)
    Parses text from a string to produce a Date. 
    The method attempts to parse text starting at the index given by pos. If parsing succeeds, then the index of pos is updated to the index after the last character used (parsing does not necessarily use all characters up to the end of the string), and the parsed date is returned. The updated pos can be used to indicate the starting point for the next call to this method. If an error occurs, then the index of pos is not changed, the error index of pos is set to the index of the character where the error occurred, and null is returned. 
      

  3.   

    trim是去两头的
    全去的话可以用replace,把空格替换成空字符