JDO not storing time information in Date, only stores the day
I am using Google App Engine with Java, JDO for persistence.
I have my Activity
object with timestamp
declared as Persistent and of type java.util.Date
.
public class Activity ...
{ ...
@Persistent
private Date timestamp;
...
}
All Activities stored in the database are seen with correct dTate but time information is always zero. e.g Thu Sep 09 00:00:00.
In some other SO post (not related to google-app-engine though), I read we should use java.sql.Timestamp instead of Date in some cases, but GAE only supports java.util.Date.
One solution is always there to use 'long' to store the time information, but is there any better/preferred way开发者_JS百科 to do this ?
So far I could not get any solution. I replaced the 'Date' with 'long' (indicating time in milliseconds) as mentioned in the question.
精彩评论