GregorianCalendar calendar = new GregorianCalendar();
String sdt = calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-" + calendar.get(Calendar.DATE);
这个是得到类似于yyyy-mm-dd的时间格式,相信你能看出如何写出你要的格式了。

解决方案 »

  1.   

    Calendar calendar = Calendar.getInstance();
    然后使用Calendar中的方法就可以了。
      

  2.   

    SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd");
          String time=formatter.format(new Date());//得到当前时间
      

  3.   

    public static String getSysDateTime() {
    String dateTime = "";
    Date sysDate = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
    StringBuffer tb = new StringBuffer();
    dateTime = sdf.format(sysDate , tb, new FieldPosition(0)).toString();
    return dateTime;
    }
      

  4.   

    你需要看一看api doc里的Calendar类,
    jackkui(键盘上的武士)的回复是最为简捷的方法,
    楼主使用的方法在1.4版本之后已经不支持了。
      

  5.   

    public abstract class Calendar
    extends Object
    implements Serializable, Cloneable, Comparable<Calendar>The Calendar class is an abstract class that provides methods for converting between a specific instant in time and a set of calendar fields such as YEAR, MONTH, DAY_OF_MONTH, HOUR, and so on, and for manipulating the calendar fields, such as getting the date of the next week. An instant in time can be represented by a millisecond value that is an offset from the Epoch, January 1, 1970 00:00:00.000 GMT (Gregorian).
      

  6.   

    Date date = new Date() 就完了,你怎么那么麻烦???