java - How to put value of day of month in my code -


how store string variable in date object? getting error:

an error occurred @ line: 25 in jsp file: /date.jsp formatter cannot resolved

 <%     try      {        calendar date = calendar.getinstance();        date.set(calendar.day_of_month, 1);        date date1;        dateformat df = new simpledateformat("dd/mm/yyyy");        string str=df.format(date.gettime());        //out.println(str); showing date formate 01/03/2014         date1 = (date)df.parse(str);         out.println(date1); //but showing "sat mar 01 00:00:00 ist 2014" want show 01/03/2014     }     catch(exception e)     {     }  %> 

when print date, build string using java.util.calendar's .get() method.

string datestr = date.get(calendar.year) + "/" + (date.get(calendar.month)+1) + "/" + date.get(calendar.day_of_month); out.print(datestr); 

and put them in whatever order want them in. if need time element, @ documentation java.util.calendar see other elements can used parameter .get() method.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -