I want to do date and time safely, so I followed several pieces of SO advice saying to use DateTimeFormatter
, so I pasted in 3 lines:
LocalDate date = LocalDate.now();
String text = date.format(formatter);
LocalDate parsedDate = LocalDate.parse(text, formatter);
Not surprisingly I got Cannot resolve symbol...
for just about everything. Been there, done that. Put cursor on error routine and hit Alt+Enter
and the proper import
will be generated.
But that didn't happen.
So I inserted these two lines as in another sample code snippet:
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
Error: `Cannot resolve symbol LocalTime` and `DateTimeFormatter`
My question is: What should I do to resolve the symbols causing the error.
I'll go on. I'm submitting more because usually when I intend to submit a Question, I figure it out my own Answer during the process of explaining what I intended to submit.
Not this time.
(Why do I have
C:\Users\Dov\AppData\Local\Android\sdk
and
C:\Users\Dov\AppData\Local\Android\sdk1
?
It doesn't matter which I select for SDK manager. Both are up-to-date, it says.
{I know this is gonna be embarrassing. I've been doing this too long (maybe I should stop here) for this to be holding me back. }
I have checked Use embedded jdk
.
I looked at every Setting I can think of.
I've Googled the error message.
I've done Clean
(no errors) and Build
.
import static...
changes nothing.
I'm using Java 8, version 51, Android Studio 2.3.3, gradle-3.3
Gradle console says:
C:\Users\Dov\Google Drive\AndroidStudioProjects\WordyHelperton - Copy - Copy
\app\src\main\java\com\dslomer64\servyhelperton\Utilities.
java:9: error: package java.time.format does not exist
And:
C:\Users\Dov\Google Drive\AndroidStudioProjects\WordyHelperton - Copy - Copy
\app\src\main\java\com\dslomer64\servyhelperton\Utilities.
java:321: error: cannot find symbol
I have this:
And this:
package java.time.format;
public final class DateTimeFormatter {
private final java.time.format.DateTimeFormatterBuilder.CompositePrinterParser printerParser;
private final java.util.Locale locale;
private final java.time.format.DecimalStyle decimalStyle;
private final java.time.format.ResolverStyle resolverStyle;
private final java.util.Set<java.time.temporal.TemporalField> resolverFields;
private final java.time.chrono.Chronology chrono;
private final java.time.ZoneId zone;
public static final java.time.format.DateTimeFormatter ISO_LOCAL_DATE;
...