【发布时间】:2014-03-12 02:13:01
【问题描述】:
我正在尝试将字符串格式化为日期,但出现 java 编译器错误:
代码片段是:
String value = String.valueOf(entry.getValue());
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
//String dateInString = value;
SimpleDateFormat parse = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);
if (isFirst){
Date date = parse.parse(value);
//Then I'll just put the date variable into a cell in the html table.
我得到的错误:
找不到符号
[javac] symbol : constructor SimpleDateFormat(java.lang.String,java.util.Locale)
[javac] location: class com.lb.base.util.extra.SimpleDateFormat
[javac] SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
[javac] ^
我在声明新的 SimpleDateFormat 的时候都得到了这个。我已经检查过导入不是问题。对它是什么感到很困惑..为什么我会收到这个“找不到符号”的错误?
【问题讨论】:
-
"我已经检查过导入不是问题" => 你确定吗? =>
location: class com.lb.base.util.extra.SimpleDateFormat -
您导入了错误的 SimpleDateFormat