Reputation: 862
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
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