I have a SQLite DB for my Android app project and I would like to save a date from a Date Picker. TO be as efficient as possible, I cannot insert that date as a String. So I'm trying to save my date as an Integer or a Long but I check all around the web and nothing clear enough to help me...
Here is my code:
public DatePickerDialog.OnDateSetListener myDateListener = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int month, int day) {
// Do something with the chosen date
TextView dateView = (TextView) findViewById(R.id.newdatepicked);
// Create a Date variable/object with user chosen date
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(0);
cal.set(year, month, day, 0, 0, 0);
Date date = cal.getTime(); // CAN I USE THIS LINE?
// Format the date using style MEDIUM and FR locale
DateFormat df_date = DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE);
String dateDF= df_date.format(dateDF);
// Display the formatted date
dateView.setText(dateDF);
}
};
And my code to insert all my data:
public void SaveAlert(View v) {
String Article = tvArticle.getText().toString();
long DateEntree = calendar.getTimeInMillis(); // This line is working very well
long DateSortie = ;///////// I CANNOT FIND OUT HOW TO HANDLE THIS ...
My issue is with DateSortie.
Please let me apologize for my English and thanks a lot for your help