سؤال

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.

هل كانت مفيدة؟

المحلول

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)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top