如题

解决方案 »

  1.   

    SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String str = sdf1.format(iDate);
      

  2.   

    Calendar ca = Calendar.getInstance() ;
         Date date = c.getTime() ;
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         System.out.println(sdf.format(date));
      

  3.   

    我就是不想再用java不推荐使用的Date类了,才问用Calendar怎么弄的
      

  4.   

    public static String getCurrentssTime() { SimpleDateFormat formatter;
    Date currentDate;
    String now;
    formatter = new SimpleDateFormat("yyyy/MM/dd/ HH:mm:ss", Locale
    .getDefault());
    currentDate = new Date();
    now = formatter.format(currentDate);
    return now;
    }
      

  5.   

    不想再用Date类,只用Calendar类没有办法了?
      

  6.   

    自己写一个方法StringBuffer sb = new StringBuffer();
         sb.append(c.get(Calendar.YEAR));
         sb.append("-");
         sb.append(c.get(Calendar.MONTH));
         sb.append("-");
         sb.append(c.get(Calendar.DAY_OF_MONTH));
         sb.append(" ");自己去完成吧
    注意十位补零
      

  7.   

    import java.util.*;
    import java.text.*;
    public class Time{
      public static void main(String[] args){
        Calendar now = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String s = "";
        s = sdf.format(now.getTime());
        System.out.println(s);
      } 
    }