如何取得系统时间 Date d = new Data();等到的d就是系统时间 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 同意楼上。Calendar cal = Calendar.getInstance();Date dt = cal.getTime(); 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 就是你所说的那种格式 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 格式的日期和时间。 Date d = new Date(); DateFormat f = DateFormat.getDateTimeInstance(); System.out.println(f.format(d));//f.format(d)就是你想要的。 注意24小时制的话,格式是: yyyy-MM-dd HH:mm:ss 其中 HH 大写hh小写是12小时制的。 getYear();getMonth();getDay();... 急急急!java中一个类调用另一个类的链表问题, 关于二进制运算 请教高手 一道有关算法的面试题 无效的描述符索引 本人即将毕业,面临就业压力,欲高薪请J2EE家教一名 java Swing编程的重绘问题,高手请进! 工具栏按钮图标问题 window下dll文件的解释 高分求教:关于日期的问题! map不能返回第一行的value Applet显示不出来?急! 如何判断String为空?
Date dt = cal.getTime();
import java.util.Date;SimpleDateFormat sdtformat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date dt = new Date();
String strdt = sdtformat.format(dt);返回的strdt 就是你所说的那种格式
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 格式的日期和时间。
DateFormat f = DateFormat.getDateTimeInstance();
System.out.println(f.format(d));//f.format(d)就是你想要的。
hh小写是12小时制的。
getMonth();
getDay();
...