我在代码中使用时间遇到了一些麻烦:
txtDauer = new JFormattedTextField();
txtDauer.setFormatterFactory(new DefaultFormatterFactory(
new DateFormatter(DateFormat.getTimeInstance())));
当我对上述 FormattedTextfield 使用 setValue(0) 时,文本字段显示 01:00:00 而不是 00:00:00。
使用此方法的另一行代码也会出现同样的问题:
public static String convertLongToString(Long time) {
String strtime = new SimpleDateFormat("HH:mm:ss").format(time);
return strtime;
}
将此方法与“0”一起使用,它会返回 strtime =“01:00:00”。