Salim Lyoussi Salim Lyoussi - 22 days ago 9x
Java Question

How to get current date in spring form of jsp page

Please i want to know how to get the current date in a form of jsp page using spring .Is there a jsp tag for that or maybe a library ? here is my code :

<form:input path="date" value=" " /> </form:form>

What should i write in the value to get the current date ?

Thank you ,


You can pass it from your controller by using java classes like java.util.Date or java.util.GregorianCalendar

Here is simple use for class Date.

Date date = new Date();

what give you String like this.

Sat Oct 01 21:02:33 AMT 2016

Here is simple use for class GregorianCalendar.

Calendar calendar = new GregorianCalendar();

What returns you object with type java.util.Date or you can take what property you want with method get like this


Convert it to String how you want and than pass to your jsp page.