The import java.text.SimpleDateFormat cannot be resolved

6.3k Views Asked by At

I use Java 15 for my example. I used Eclipse IDE for Java Developers - 2020-12.

I got an error shown below when I define SimpleDateFormat to handle with formating a date object.

import java.text.SimpleDateFormat; // error -> The import java.text.SimpleDateFormat cannot be resolved

How can I fix my issue?

2

There are 2 best solutions below

6
Wakawey On

Try selecting the correct Execution environment or alternate JRE:

Build Path --> Configure Build Path --> Libraries --> Double click JRE System Library.

0
Raul Lapeira Herrero On

Just copying Basil comment without the toxicity:

SimpleDateFormat class was supplanted some time ago by java.time classes defined in JSR 310. Specifically replaced by java.time.DateTimeFormatter