How can i get current date and time in android and store it into string -
currently using code below:
string currentdatetimestring = dateformat.getdatetimeinstance() .format(new date()); from getting output in following format -
jun 5, 2015 1:15:29 pm
but want output in format below-
2015-06-05 08:10:40 it can in 12 or 24 hour format.
i want current date time above datetime format.
i have use simpledateformat not able above date time format current date , time
so, how can achieve this?
use simpledateformat
date curdate = new date(); simpledateformat format = new simpledateformat("yyyy-mm-dd hh:mm:ss a"); string datetostr = format.format(curdate); system.out.println(datetostr);
Comments
Post a Comment