Date d = new Data();
等到的d就是系统时间

解决方案 »

  1.   

    同意楼上。Calendar cal = Calendar.getInstance();
    Date dt = cal.getTime();
      

  2.   

    import java.text.SimpleDateFotmat;
    import java.util.Date;SimpleDateFormat sdtformat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    Date dt = new Date();
    String strdt = sdtformat.format(dt);返回的strdt 就是你所说的那种格式
      

  3.   

    import java.text.SimpleDateFormat;
    import java.util.Date;
    ......SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
    Date date = new Date(System.currentTimeMillis());
    String strDate = formatter.format(date);
    ......
    字符串strDate 中就是 yyyy-MM-dd HH:mm:ss 格式的日期和时间。
      

  4.   

    Date d = new Date();
            DateFormat f = DateFormat.getDateTimeInstance();
            System.out.println(f.format(d));//f.format(d)就是你想要的。
      

  5.   

    注意24小时制的话,格式是:  yyyy-MM-dd HH:mm:ss 其中 HH 大写
    hh小写是12小时制的。
      

  6.   

    getYear();
    getMonth();
    getDay();
    ...