java - How can i get data in format "YYYY-MM-DD 00:00:00.0" using class Date? -


how can data in format "yyyy-mm-dd 00:00:00.0" using class date (it's extremly important use class)?

i tried can think of:

simpledateformat sdf = new simpledateformat("yyyymmdd"); df.format(date) 

and

string pattern = "yyyy-mm-dd hh:mm:ss.s"; simpledateformat format = new simpledateformat(pattern); try { date date = format.parse("2011-01-18 00:00:00.0"); } catch (parseexception e) { e.printstacktrace(); } 

byt when print date using logger format "tue sep 30 00:00:00 msk 1913".

try this

    simpledateformat format = new simpledateformat("yyyy-mm-dd hh:mm:ss.s");     date date = format.parse("2011-01-18 00:00:00.0");     system.out.println(format.format(date)); 

Comments