strutsprog06
Programmer
I have date saved in my oracle table as:7/24/2006 12:16:53
When i Run a query like this:
select date_created from post;
It returns result like: 2006-07-24 12:16:53
I want to display the date like Mon, Jul 24, '06.
In my view of this line:
<bean:write name='browseall2' property="value(date_created)" filter='true' />
How should i do it.
i used simple format java function like this:
public String formatDate(String dates){
String returnDate = "";
Date tempDate=null;
if(dates != null && dates.length() > 0){
try{
//from timestamp date replace - with /
String repDate= dates.replace('-','/');
//System.out.println(repDate);
tempDate = new SimpleDateFormat("yyyy/MMM/DD hh:mm:ss").parse(repDate);
// System.out.println("tempDate " + tempDate);
returnDate = new SimpleDateFormat("EEE, MMM d, ''yy").format(tempDate);
// System.out.println("returnDate " + returnDate);
}catch(Exception e){
e.printStackTrace();
}
}
return returnDate;
}
}
But it id getting confuse on month and 07 always became Month Jan.
If I use mm/dd/yyyy instaed of this yyyy/MMM/DD hh:mm:ss
It messes up more
date is taken as month and other wrong things.
I tried this also:
<bean:write name="topic" property='value(date_created)' formatKey="my.own.format.key" />
It gived no error but does not do anything:
Date displayed on view is like this:
2006-07-24 12:16:53
I want to dispaly Mon Jul 24, '06
Please guide.
When i Run a query like this:
select date_created from post;
It returns result like: 2006-07-24 12:16:53
I want to display the date like Mon, Jul 24, '06.
In my view of this line:
<bean:write name='browseall2' property="value(date_created)" filter='true' />
How should i do it.
i used simple format java function like this:
public String formatDate(String dates){
String returnDate = "";
Date tempDate=null;
if(dates != null && dates.length() > 0){
try{
//from timestamp date replace - with /
String repDate= dates.replace('-','/');
//System.out.println(repDate);
tempDate = new SimpleDateFormat("yyyy/MMM/DD hh:mm:ss").parse(repDate);
// System.out.println("tempDate " + tempDate);
returnDate = new SimpleDateFormat("EEE, MMM d, ''yy").format(tempDate);
// System.out.println("returnDate " + returnDate);
}catch(Exception e){
e.printStackTrace();
}
}
return returnDate;
}
}
But it id getting confuse on month and 07 always became Month Jan.
If I use mm/dd/yyyy instaed of this yyyy/MMM/DD hh:mm:ss
It messes up more
date is taken as month and other wrong things.
I tried this also:
<bean:write name="topic" property='value(date_created)' formatKey="my.own.format.key" />
It gived no error but does not do anything:
Date displayed on view is like this:
2006-07-24 12:16:53
I want to dispaly Mon Jul 24, '06
Please guide.