自己分别取出年月日的实际值再放到Date对象中啊

解决方案 »

  1.   

    DataFormat.parse()好像解不了中文字符吧,还是自己写方法实现罗
      

  2.   

    import java.text.*;
    import java.util.*;
    public class DateFormatTest { public static void main(String[] args) {
    Locale locale = Locale.CHINESE; DateFormat formatter = new SimpleDateFormat("yyyy年mm月dd日", locale); try{
    Date date = (Date)formatter.parse("2005年1月6日");
    System.out.println(date);
    int a = 10;
    }
      catch (ParseException e) {
        }
    }
    }
      

  3.   

    DateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日");
    Date d=sdf.parse("2005年01月6日");
      

  4.   

    注意:
    M:表示月份 Month 
    m:表示分钟 minute
      

  5.   

    import java.util.Date;
    import java.util.Locale;
    import java.text.DateFormat;public class MyDate{
    public static void main(String[] args) throws Exception{
    String adate = "2005年1月6日";
    DateFormat df = DateFormat.getDateInstance(
         DateFormat.LONG, Locale.SIMPLIFIED_CHINESE);//CHINA CHINESE
    Date d = df.parse(adate);
    // System.out.println(df.format(d));
    int day = d.getDate();
    int month = d.getMonth();
    int year = d.getYear();
    System.out.println("year=" + year + " month=" + month + " day=" + day); String odate = "2005/1/6";
    d = new Date(odate);
    day = d.getDate();
    month = d.getMonth();
    year = d.getYear();
    System.out.println("year=" + year + " month=" + month + " day=" + day);
    }
    }
      

  6.   

    DateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日");
    Date d=sdf.parse("2005年01月6日");