Tag: 格式

java.util.Date格式SSSSSS:如果不是微秒,那么最后3位数是多少?

刚刚在我的Windows(8)工作站和AIX上测试了这段代码: public static void main(String[] args) { System.out.println(new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss.SSSSSS”).format(new Date())); System.out.println(new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss.SSSSSS”).format(new Date())); } 并得到类似的结果: 2013-10-07 12:53:26.000905 2013-10-07 12:53:26.000906 有人可以解释一下,如果不是微秒,最后的数字是什么? 注意:我与DB2数据库进行交互,其中使用定时列作为TIMESTAMP存储按时间顺序排列的数据,其中6位数字在秒之后,即微秒(IMO)。 但是所有这些“时间戳”都是通过请求以下查询来创建的: SELECT current timestamp as currenttimestamp FROM Table ( values (1)) temp 我想知道,鉴于上述结果,我不能只在我的代码中使用new Date()而不是从数据库中选择current timestamp 。 谢谢。 PS:我搜索过但发现没有相关(已回答)的问题,例如: java中的当前时间(以微秒为单位)或以小时,分钟,秒,毫秒,微秒获取时间

String类型中的方法格式(String,Object )不适用于参数(…)

这是我的代码: int hoursFormat = 1, minsFormat = 2, secsFormat = 3; String timeFormat = String.format(“%02d:%02d:%02d”,hoursFormat, minsFormat, secsFormat); 这给出了编译错误: Unresolved compilation problem: The method format(String, Object[]) in the type String is not applicable for the arguments (String, int, int, int) 为什么我在这里收到此错误,如何解决?

SwingWorker没有响应

我想做什么? 单击Start JButton , SwingWorker将执行。 在doInBackground()方法中,我将arrNames每个索引传递给publish()方法,以便它可以显示在JTextArea 。 发生了什么 ? 如果我不保持行System.out.format(“Counter : %d%n”, counter); 作为注释 ,在我的SwingWorker doInBackground()方法中,然后SwingWorker 按预期工作 。 虽然如果我发表评论 ,那么SwingWorker 停止响应 。 难道我做错了什么 ? Java版本: java version “1.7.0_25” Java(TM) SE Runtime Environment (build 1.7.0_25-b16) Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode, sharing) 这是我正在使用的代码: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class SwingWorkerExample1 { private […]