i have date object using method gettime return milliseconds since 1/1/1970.
invoicedate.gettime(); these milliseconds passed java.sql.date constructor so:
new java.sql.date( invoicedate.gettime() ); and result date in yyyy-mm-dd format.
now question this, possible java.sql.date can produce off 1 error? example, invoicedate set thu jul 02 00:00:00 cdt 2015, possible java.sql.date produces 2015-07-01?
no. java date not store timezone invoicedate , new date object equal. prints cdt in tostring() because timezone of jvm
also see docs date.gettime()
returns number of milliseconds since january 1, 1970, 00:00:00 gmt represented date object.
and date(long)
allocates date object , initializes represent specified number of milliseconds since standard base time known "the epoch", namely january 1, 1970, 00:00:00 gmt.
Comments
Post a Comment