给定一个java.util.Date对象,如何转化为"2007-3-22 20:23:22"格式的字符串。

解决方案 »

  1.   

    SimpleDateFormat sdf = new SimpleDateFormat(yyyy-MM-dd hh:mm:ss);  
    sdf.format(date);
      

  2.   

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");  
    参数字符串
      

  3.   

    SimpleDateFormat sdf = new SimpleDateFormat(yyyy-MM-dd hh:mm:ss);  
    sdf.format(date);
    真的很简单啊
      

  4.   

    SimpleDateFormat sdf = new SimpleDateFormat(yyyy-MM-dd hh:mm:ss);  
    sdf.format(date);
      

  5.   

    SimpleDateFormat dateFormatter = (SimpleDateFormat)simpleDateFormat.clone();
     dateFormatter.applyPattern(YYYYMMDDHH24MISS("yyyyMMdd hh:mm:ss a"));
     dateFormatter.applyLocalizedPattern(YYYYMMDDHH24MISS("yyyyMMdd hh:mm:ss a"));
     str = dateFormatter.format(dtDate);