G.S Abhaypal G.S Abhaypal - 1 year ago 113
Java Question

Date() is showing error regarding mismatched parameters

i have tried these lines in my code

DateFormat df = new SimpleDateFormat("dd/MM/yy");
String formattedDate = df.format(new Date());

But Date() is showing some error like no suitable constructor found for Date() and constructor Date.Date(long) is not applicable(actual and formal argument list differ in length). I have searched alot but didnt found any answer. I just want a date in simple format. Help !!
I tried giving a argument like

String formattedDate=df.format(new Date(0));

but it displayed a date like 1/1/70.

Answer Source

You must have imported wrong Date class, Make sure you import java.util.Date;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download