Sikander
Sikander

Reputation: 862

Date field not working properly in grails

I have a lastLogin field in my User domain class with type Date. I use it to track the last login date with time. When a user logs in successfully I change this field value as under,

someUser.lastLogin = new Date()
 someUser.save()

When I view that user in list the lastLogin value looks like this 2014-38-12 04:38:40 i.e the month in the date is replaced by the time. Every time I try, this occurs. Help will be appreciated.

Upvotes: 1

Views: 138

Answers (1)

tim_yates
tim_yates

Reputation: 171054

Have you specified a Date format (for when you output the date) like:

'yyyy-mm-dd HH:mm:ss'

That is incorrect, you need:

'yyyy-MM-dd HH:mm:ss'

(note: capital M for Month)

Upvotes: 4

Related Questions