How to insert date in ActiveRecord !
deshario opened this issue · 1 comments
deshario commented
naXa777 commented
ActiveAndroid supports serializing Date fields automatically. It is stored internally as a timestamp (INTEGER
) in milliseconds.
@Column(name = "timestamp", index = true)
private Date timestamp;
Create a Util method to convert String
to Date
, if you want:
public Date getDateFromString(String selectedDate) throws ParseException{
DateFormat format = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH);
Date date = format.parse(selectedDate);
return date;
}
ps. ActiveAndroid has a pretty strong community on Stack Overflow, so you're welcome to ask your questions there. Actually this answer is copied from the Stack Overflow.