public class Text1 {
  public static void main(String[] args) throws java.text.ParseException{
  SimpleDateFormat dd=new SimpleDateFormat("yyyyMMdd");
  String d=dd.format(new Date());
  System.out.println(d);
  String ddd="2007-11-21";
 

  }
}

解决方案 »

  1.   

     那你直接 SimpleDateFormat dd=new SimpleDateFormat("yyyyMMdd"); 这种格式就行了呗
      

  2.   

    你接口是什么数据类型 日期类型是java.util.date 什么格式都是format后的字符串
      

  3.   


    import java.text.SimpleDateFormat;
    import java.util.Date;public class Test {
    public static void main(String[] args) throws java.text.ParseException {
    String oldStr="2007-11-21";
    String newStr=null;
    Date oldDate,newDate;
    SimpleDateFormat oldSdf = new SimpleDateFormat("yyyy-MM-dd");
    oldDate=oldSdf.parse(oldStr);
    newStr=String.valueOf(oldDate.getYear()+1900)+String.valueOf(oldDate.getMonth()+1)+String.valueOf(oldDate.getDate());
       
        System.out.println(newStr);
    }
    }/*
    20071121
    */
      

  4.   

    string time = "";
    Date newDate;
    Date date = new Date();
    SimpleDateFormat  sdf = new SimpleDateFormat("yyyyMMdd");
    time = sd.format(date);//这是字符串型
    try{
       newDate = sdf.parse(time);//String类型转换成Date类型
    }catch(Exception e){
       e.printStackTrace();
    }