如何取得系统时间 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();... 请问NEW的具体用法 java 带jdbc.jar的运行问题 今天写了两个控制台小游戏,与大家分享 Eclipse 3.4 安装 SWT Desinger 6.7.0 谁有 请问UDP协议的同步问题,高手指点啊? java问题?? 请给一个Together For Eclipse 6.1 及 Keygen的下载地址,先给20分,解决后再开贴给100分 疑问:关于线程,如果有过个变量和方法,是需要共享的。。。。。。 constructor一题????? 我是初学者,关于java的编辑、运行、调试、及工具等的问题?望各位大侠帮忙! 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();
...