我的时间格式如下
public static final String TIME_FORMAT = "HH:mm:ss.SS";
edition.getEditionDate().format(TIME_FORMAT);
输出如下:
15:02:08.293
我应该如何获得以下输出。我不想使用Joda Time 。我不想使用 substring() 方法,因为它不是一种有效的方法。
15:02:08.29
无法使用 SimpleDateFormat,因为 Gwt 客户端代码不支持。 Methods supported by GWT client side code
最佳答案
SimpleDateFormat dateFormat = new SimpleDateFormat ("HH:MM:ss.");
DecimalFormat fractionalformat = new DecimalFormat ("00");
Date date = new Date ();
String str = dateFormat.format (date) + fractionalformat.format (date.getTime () % 1000L / 10L);
System.out.println (str);
关于java - 将 GWT 中的时间值格式化为 HH :mm:ss. SS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15331651/