Exception in thread "main" java.lang.NumberFormatException: For input string: "2016/09/12 09:41:48"
来源:互联网 发布:美国ela数据 编辑:程序博客网 时间:2024/05/26 19:19
挺奇怪的一个问题,可能是自己本身的基础不牢固所以困扰了很久!
本来是想要把文件的最后访问时间改为当前的时间,然后获取时间是这样的:
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());
先贴到这儿,有时间再继续研究吧!
0 0
- Exception in thread "main" java.lang.NumberFormatException: For input string: "2016/09/12 09:41:48"
- java.lang.NumberFormatException: For input string
- java.lang.NumberFormatException: For input string:
- java.lang.NumberFormatException: For input string: "bobo"
- java.lang.NumberFormatException: For input string: "imei"
- java.lang.NumberFormatException: For input string: "0 "
- java.lang.numberformatException:For input string ""
- java.lang.NumberFormatException: For input string: ""
- java.lang.NumberFormatException: For input string: "undefined"
- java.lang.NumberFormatException: For input string: "on"
- java.lang.NumberFormatException: For input string: ".0"
- Error: java.lang.NumberFormatException: For input string: ""
- java.lang.NumberFormatException: For input string: "|"
- java.lang.NumberFormatException: For input string: ""
- java.lang.NumberFormatException: For input string: "33287333543937"
- java.lang.NumberFormatException: For input string: "undefined"
- Exception in thread "main" java.lang.NoSuchMethodException: xxx.main([Ljava.lang.String;)
- Exception in thread "main" java.lang.NoClassDefFoundError
- Make编译学习笔记(一)Makefile基础
- Android 6.0 运行时权限管理最佳实践
- 5.1.1 读取Redis 数据
- objective-c 正则表达式 -NSRegularExpression 提取匹配内容
- 电脑行业的变革
- Exception in thread "main" java.lang.NumberFormatException: For input string: "2016/09/12 09:41:48"
- 有趣的圣诞树
- 教师资格证
- 数据库管理工具设置数据同步的方法
- 字符与数字之间的转换
- ionic开发——浏览器打开链接功能
- Ruby学习记录 - 安装Ruby
- 满足这些条件,跳槽才能换加薪!
- JavaScript 函数的特点