tags:

views:

385

answers:

3

Hi

I am pulling a column from database which contains date.In DB it is character value.I want to print the date in formatted way. I have used following code for printing the date in formatted manner.

where ${Po[1]} contains date value.

But above statement prining null value.

Any advice

Thanks in advance

Sas

A: 

Use a JSTL format tag, of course:

<fmt:date etc.>

http://www.java2s.com/Code/Java/JSTL/JSTLFormatDate.htm

Why your value is null is another matter. Po[1] isn't being set properly. How does that value get entered into the page?

duffymo
A: 

Po[1] is populated by a SQL statement.When i normally print this value${Po[1]} it is printing the date properly.I want to format this date.

Thanks

Sas

A: 

JSTL library expects object of Date datatype (java.util.Date). You will have to parse the String data into java.util.Date using either java.sql.Date.valueOf or java.util.Date.parse function.

If you dont prefer to create an object of java.util.Date for any reason then you can use JavaScript function to format the Date string

Rutesh Makhijani