JAVA中如何得到系统的日期和时间?

解决方案 »

  1.   

    java.util.Date
             .Canlendar
    System
      

  2.   

    定义一个Date类,然后用getTime方法获取时间!
      

  3.   

    long time = System.currentTimeMillis();
    Date now = new Date(time);
    SimpleDateFormat df = new SimpleDateFormat("yyMMddHHmmss");
    String strId  =df.format(now);
    System.out.println(strId);
      

  4.   

    to get Time using:  (Calendar.getInstance()).get(int HMS);
                       param HMS could be Calendar.HOUR_OF_DAY
                                          Calendar.MINUTE
                                          Calendar.SECOND
                       method get(int ) return int-type value of the 
                                        specified param 
      

  5.   

    我是这样做的 
    private DateFormat formater;
    private String currentdate;
    private Date today;
    private Locale loca;
    loca=Locale.getDefault();
    formater=DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.MEDIUM,loca);
    today=new Date();
    currentdate=formater.format(today);
    自我感觉这样好一点,java tutorial也是这样写的