Java Compiler Issue: cannot find symbol
NickName:stretchr Ask DateTime:2014-03-12T10:13:01

Java Compiler Issue: cannot find symbol

I am trying to format a String into a date but getting java compiler error:

The fragment of code is:

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. 

The error I am getting:

cannot find symbol

 [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]                                                          ^

I get this for both times I am declaring new SimpleDateFormat. I have checked that import is not the issue. Quite confused to what it is then..why am I getting this 'cannot find symbol' error?

Copyright Notice:Content Author:「stretchr」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/22340643/java-compiler-issue-cannot-find-symbol

Answers
stretchr 2014-03-12T02:31:11

Thanks folks, I fixed it by commenting out the first import\ncom.lb.base.util.extra.SimpleDateFormat \n\nand adding \n\nimport java.text.SimpleDateFormat; \n\nbelow it. Guess we can't let the two imports happen at the same time. ",


user695992 2014-03-12T02:14:36

Your import seems to be off. You want to use java's SimpleDataFormat and not com.lb.base.util.extra whatever that is.",


saladinxu 2014-03-12T02:15:49

Apparently you're trying to import com.lb.base.util.extra.SimpleDateFormat\n\nDid you mean to import the java.text one? If yes try changing to below:\n\nimport java.text.SimpleDateFormat;\n\nOr change the line you call the constructor:\n\njava.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat(\"yyyy-MM-dd\", Locale.ENGLISH);",


More about “Java Compiler Issue: cannot find symbol” related questions

Java Compiler Issue: cannot find symbol

I am trying to format a String into a date but getting java compiler error: The fragment of code is: String value = String.valueOf(entry.getValue()); SimpleDateFormat formatter = new SimpleDateF...

Show Detail

Cannot Find Symbol compiler message

Hello all I'm a java newbie and I'm getting a compiler error message: src\LU62XnsCvr.java:33: cannot find symbol symbol : constructor File(java.lang.StringBuffer) location: class java.io.File ...

Show Detail

Compiler error cannot find symbol - Java

First, I am very new to Java and my programming in general is rusty. So I might have missed something very simple. The error: cannot find symbol symbol : method setMethod(java.lang.String) locat...

Show Detail

Java compiler says cannot find symbol. why?

I followed this: https://mahout.apache.org/users/recommender/userbased-5-minutes.html and my codes : pom.xml Note that my <groupId> is also org.apche.mahout <project xmlns="http://maven.

Show Detail

Learning java, cannot find symbol

I'm learning Java and stuck on a self test exercise writing a recursive function that prints a string backwards... I understand the compiler error but I'm not sure what to do about it. My code...

Show Detail

Java Compiler API (Linux): cannot find symbol for custom classes

I have a rather specific problem with the Java Compiler API. For my Usecase I have to generate, compile and load a java-class at runtime in my Web-Application (using Tomcat). In order to do that, I

Show Detail

maven compiler 3.1 cannot find symbol

for the error reproduction, I created a demo project: https://github.com/boyang9602/demo . I have read Maven compile "Cannot find symbol", What does a "Cannot find symbol" or &q...

Show Detail

Java compiler error. Cannot find symbol

Why am I getting this error when the SystemController class is in the same directory? sgs$ javac Main.java Main.java:27: cannot find symbol symbol : class SystemController location: class sgs.M...

Show Detail

Variable declared, compiler cannot find symbol

So for a project I'm working on this program. It's intended to take an input from the user and use it to convert the measurement. I'm getting these errors: ConversionWilson.java:69: error: cannot ...

Show Detail

Java Netbeans Cannot Find Symbol

I am working through a practice assignment in my Java Programming Textbook and have encountered the common "error: cannot find symbol". I have to create an application that refers to anot...

Show Detail