java - Trying to save current date permentently -
simpledateformat sdf = new simpledateformat("dd/mm/yyyy hh:mm"); date = new date(); string strdate = sdf.format(now);
i trying display current date permanently.
i have tried:
date = new date(); string strdate = sdf.format(now);
but returning error
since have not posted error, , looking @ code looks fine, best guess getting following error:
error: no suitable constructor found date() date = new date(); constructor date.date(long) not applicable (actual , formal argument lists differ in length) constructor date.date(int,int,int) not applicable (actual , formal argument lists differ in length) 1 error
which happens when use java.sql.date
instead of java.util.date
, since simpledateformat.format()
accepts parameter of type java.util.date
.
change import statement import java.util.date
or worst case, have not added imports add following:
import java.util.date import java.text.simpledateformat
Comments
Post a Comment