Exception in thread "main" java.lang.NumberFormatException: For input string: "2016/09/12 09:41:48"
2016-09-12 09:48
1186 查看
挺奇怪的一个问题,可能是自己本身的基础不牢固所以困扰了很久!
本来是想要把文件的最后访问时间改为当前的时间,然后获取时间是这样的:
给文件设置最后访问时间是这样的:
然后就报错了!
格式转换出错了,解决的办法是用了另一个获取时间的办法!
先贴到这儿,有时间再继续研究吧!
本来是想要把文件的最后访问时间改为当前的时间,然后获取时间是这样的:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); String nowDate = sdf.format(date);
给文件设置最后访问时间是这样的:
file.setLastModified(Long.parseLong(nowDate));
然后就报错了!
Exception in thread "main" java.lang.NumberFormatException: For input string: "2016/09/12 09:41:48" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Long.parseLong(Long.java:441) at java.lang.Long.parseLong(Long.java:483) at ParesLongTest.main(ParesLongTest.java:15)
格式转换出错了,解决的办法是用了另一个获取时间的办法!
file.setLastModified(System.currentTimeMillis());
先贴到这儿,有时间再继续研究吧!
相关文章推荐
- 经典面试题, Exception in thread "main" java.lang.NumberFormatException: input string: ""
- 执行Hive时出现org.apache.hadoop.util.RunJar.main(RunJar.java:136) Caused by: java.lang.NumberFormatException: For input string: "1s"错误的解决办法(图文详解)
- java.lang.NumberFormatException: For input string: "0"
- java.lang.NumberFormatException: For input string: "4321432431"
- Exception in thread “main” com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: empty String
- 关于jstl EL用法的注意点(java.lang.NumberFormatException: For input string: "userName")
- 关于jstl EL用法的注意点(java.lang.NumberFormatException: For input string: "userName")
- java.lang.NumberFormatException: For input string: ".0"
- el 表达式 报 java.lang.NumberFormatException: For input string: "xxx"
- 入门:java.lang.NumberFormatException: For input string: "11"
- Error: java.lang.NumberFormatException: For input string: ""
- mybatis java.lang.NumberFormatException: For input string: "G"
- java.lang.NumberFormatException: For input string:"filesId"
- Caused by: java.lang.NumberFormatException: For input string: ""
- java.lang.NumberFormatException: For input string: "19000000000" at java.lang.NumberFormatExceptio
- Caused by: java.lang.NumberFormatException: For input string: "undefined"
- java.lang.NumberFormatException: For input string: "Y"
- java.lang.NumberFormatException: For input string: "bobo"
- 常见错误:java.lang.NumberFormatException: For input string: "6 "
- java.lang.NumberFormatException: For input string: "2013-01-03 15:16:21"