3中方式
1.
System.out.println(System.currentTimeMillis());//结果1356750251713 应用在计算时间差时可以很方便 2. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");//可以方便地修改日期格式 String hehe = dateFormat.format(new Date()); System.out.println(hehe); 3. Calendar c = Calendar.getInstance();//可以对每个时间域单独修改 int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int date = c.get(Calendar.DATE); int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); int second = c.get(Calendar.SECOND); System.out.println(year + "/" + month + "/" + date + " " +hour + ":" +minute + ":" + second); }