怎样获取系统时间,显示成“年月日时分秒”的格式? SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");String date = sDateFormat.format(new java.util.Date()); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 SimpleDateFormat formatter = new SimpleDateFormat ("yyyy.MM.dd HH:mm");formatter.format(new Date()); 上述的date应该是英文格式,应该发展一个class专门显示中文格式。 df=DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.FULL,Locale.CHINA);System.out.println(df.format(new Date())); import java.text.SimpleDateFormat;SimpleDateFormat formatter = new SimpleDateFormat ("yyyy年MM月dd日 HH:mm:ss ");Date curDate = new Date(System.currentTimeMillis());//获取当前时间String str = formatter.format(curDate);这样只是一个静止的时间,如果你想让程序中的这个显示时间时可表示当前的时间.应该利用一个线程或者直接用一个时钟.并且时钟的时间及设置为1s,每1秒刷新一次显示.比如:ActionListener listener = new ActionListener{ public void actionPerformed(ActionEvent e){ ***.setText("系统当前时间:" +formatter.format(new Date (System.currentTimeMillis())) ); //***表示你在某个组件中显示出来这些信息. }}javax.swing.Timer oneSecondTimer = new javax.swing.Timer(1000,listener);oneSecondTimer.start(); Mina使用UDP时丢包严重,急``` 在eclipse中使用Arrays.asList出错 模拟光标 拆字符串,放到ArrayList里面; 如何得到不重合的指定范围的二维数组 怎么用jbuilderx连oracle数据库!!在线等 有关String的小问题 关于汉字的读取显示问题...急!!! 高分求救,如何做个招聘网站 执行文件? 一个小调查,来者有分! Jcreator第一次启动的时候出现的对话框有什么作用,我要怎么样设置??
formatter.format(new Date());
System.out.println(df.format(new Date()));
String str = formatter.format(curDate);这样只是一个静止的时间,如果你想让程序中的这个显示时间时可表示当前的时间.
应该利用一个线程或者直接用一个时钟.并且时钟的时间及设置为1s,每1秒刷新一次显示.
比如:
ActionListener listener = new ActionListener{
public void actionPerformed(ActionEvent e){
***.setText("系统当前时间:" +formatter.format(new Date
(System.currentTimeMillis()))
);
//***表示你在某个组件中显示出来这些信息.
}
}
javax.swing.Timer oneSecondTimer = new javax.swing.Timer(1000,listener);
oneSecondTimer.start();