android - store in date format without showing all the details (GMT , time) -
is possible store current date in file no string?
what mean:
if use :
simpledateformat thedate = new simpledateformat("dd/mm/yyyy"); date d=new date(); string formatteddate=thedate.format(d); date.add(formatteddate);
it stores (with format want) in date list (which string list).
i want 'date' date list , store file.
is possible store dd/mm/yyyy ?because this:
simpledateformat thedate = new simpledateformat("dd/mm/yyyy"); date d=new date(); date.add(d);
it stores
thu apr 18 17:06:14 gmt+03:00 2013
try above code:
simpledateformat dateformat = new simpledateformat("yyyy-mm-dd"); date date = new date(); dateformat.format(date);
this not save date string(as desire) , format current date according need. haven't tested right now, have used before pretty sure works. hope helps. if not please comment.
update
i tried following:
list<date> d = new arraylist<date>(); simpledateformat dateformat = new simpledateformat("dd/mm/yyyy"); date date = new date(); string s = dateformat.format(date); try { d.add(dateformat.parse(s)); } catch (parseexception e1) { // todo auto-generated catch block e1.printstacktrace(); } log.d("try","newdatestring: "+ d.get(0)); log.d("try","newdate: "+ d.get(0).getdate()+" "+d.get(0).getmonth()+" "+(d.get(0).getyear()+1900));
it works , following result got:
newdatestring: thu apr 18 00:00:00 edt 2013 new date: 18 3 2013
so can is, save date above , when retrieving date file may choose day/month/year date object saved.
Comments
Post a Comment