java - How to use Timestamp constructor -


i want use default constructor timestamp class in java eclipse indicates deprecated. constructor:

timestamp mydate = new timestamp(2014, 3, 24, 0, 0, 0 ,0);

eclipse recommends using timestamp(long time) default constructor don't know how use it.

what next method?

int myyear = 2014; int mymonth = 3; int myday = 24; timestamp ts = timestamp.valueof(string.format("%04d-%02d-%02d 00:00:00",                                                  myyear, mymonth, myday)); 

using jsr 310: date , time api (introduced in java se 8 release):

java.sql.timestamp ts = java.sql.timestamp.valueof(         java.time.localdate.of(myyear, mymonth, myday).atstartofday() ); 

Comments

Popular posts from this blog

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -