请问如何把Thu Nov 05 09:25:45 CST 2009格式的Date转换为yyyy-MM-dd HH:mm:ss格式的Date类型,请注意是yyyy-MM-dd HH:mm:ss格式的Date类型,不是String ,先多谢了

解决方案 »

  1.   

    没有!!!!!!!!!!!!!!!!!!!!!!!
    只要是Date类型格式就是固定的,除非使用String
      

  2.   

    public static void main(String[] args) {
    Date d = new Date();
    System.out.println(DateFormat.getDateTimeInstance().format(d));
    }
      

  3.   

    DateFormat.getDateTimeInstance().format(d)还不是String型的问下楼主Date的格式是怎么看出来的?Thu Nov 05 09:25:45 CST 2009格式的Date  你是怎么看出来的?
      

  4.   

    个人认为
    不存在某种格式的Date
    只存在某种格式的输出String类型SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date d = new Date();
    System.out.println(sdf.format(d));
      

  5.   

    new SimpleDateFormat("EEE MMM dd hh:mm:ss zzz yyyy", Locale.ENGLISH).parse("Thu Nov 05 09:25:45 CST 2009");
      

  6.   

    太长了,重发一下SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd hh:mm:ss zzz yyyy", Locale.ENGLISH);
    Date date = sdf.parse("Thu Nov 05 09:25:45 CST 2009");
      

  7.   


    赞同,平时看到的只是toString()的输出方式,改写他应该就行了
      

  8.   


    说的对哦  Date是个类而已 里面的只有属性段 而没有格式 格式都是转成字符串才构造的 毕竟输出
    都是变为String输出的// 这里是Date的属性
        private static final BaseCalendar gcal =
    CalendarSystem.getGregorianCalendar();
        private static BaseCalendar jcal;    private transient long fastTime;    /*
         * If cdate is null, then fastTime indicates the time in millis.
         * If cdate.isNormalized() is true, then fastTime and cdate are in
         * synch. Otherwise, fastTime is ignored, and cdate indicates the
         * time.
         */
        private transient BaseCalendar.Date cdate;    // Initialized just before the value is used. See parse().
        private static int defaultCenturyStart;    /* use serialVersionUID from modified java.util.Date for
         * interoperability with JDK1.1. The Date was modified to write
         * and read only the UTC time.
         */
        private static final long serialVersionUID = 7523967970034938905L;    /**
         * Allocates a <code>Date</code> object and initializes it so that 
         * it represents the time at which it was allocated, measured to the 
         * nearest millisecond. 
         *
         * @see     java.lang.System#currentTimeMillis()
         *///这里是toString()函数 可以看到格式是自己构造的 是可以改变的 但都是字符串的形式表现出来
        public String toString() {
    // "EEE MMM dd HH:mm:ss zzz yyyy";
    BaseCalendar.Date date = normalize();
    StringBuilder sb = new StringBuilder(28);
    int index = date.getDayOfWeek();
    if (index == gcal.SUNDAY) {
        index = 8;
    }
    convertToAbbr(sb, wtb[index]).append(' ');   // EEE
    convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');  // MMM
    CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 2).append(' '); // dd CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');   // HH
    CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':'); // mm
    CalendarUtils.sprintf0d(sb, date.getSeconds(), 2).append(' '); // ss
    TimeZone zi = date.getZone();
    if (zi != null) {
        sb.append(zi.getDisplayName(date.isDaylightTime(), zi.SHORT, Locale.US)); // zzz
    } else {
        sb.append("GMT");
    }
    sb.append(' ').append(date.getYear());  // yyyy
    return sb.toString();
        }
      

  9.   

    楼主可以先转化为yyyy-MM-dd HH:mm:ss格式的String类型,再转为Date型啊