【发布时间】:2014-12-03 19:49:10
【问题描述】:
我正在从文件中读取时间戳数据,我希望稍后在Timer scheduler 中使用这些时间戳来根据时间戳触发一些事件。时间戳格式类似于0.012999999999,它们是字符串类型,我使用Long.parseLong 将其转换为long。我尝试了以下代码,但在运行时收到以下错误,在我看来这是关于时间戳的格式,但我不知道如何处理它。
代码:
static TimerTask timedTask = new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
}
};
Timer timer = new Timer();
timer.schedule(timedTask, Long.parseLong(logfile.getFileHash().get(1).getTimeStamp()));
错误:
Exception in thread "file processing" java.lang.NumberFormatException: For input string:
"0.012999999999"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Long.parseLong(Unknown Source)
at java.lang.Long.parseLong(Unknown Source)
at com.example.File_IO_00.File_IO.processFile(File_IO.java:77)
at com.example.File_IO_00.File_IO.access$1(File_IO.java:69)
at com.example.File_IO_00.File_IO$1.run(File_IO.java:20)
at java.lang.Thread.run(Unknown Source)
【问题讨论】:
-
时间戳格式来自哪里