Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
53 additions
and 0 deletions.
@@ -0,0 +1,28 @@ | ||
package dragosholban.com.timezoneconverter; | ||
|
||
import android.app.DatePickerDialog; | ||
import android.app.Dialog; | ||
import android.app.DialogFragment; | ||
import android.os.Bundle; | ||
import android.widget.DatePicker; | ||
|
||
import java.util.Calendar; | ||
import java.util.Date; | ||
|
||
public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { | ||
|
||
@Override | ||
public Dialog onCreateDialog(Bundle savedInstanceState) { | ||
Calendar c = Calendar.getInstance(); | ||
int year = c.get(Calendar.YEAR); | ||
int month = c.get(Calendar.MONTH); | ||
int day = c.get(Calendar.DAY_OF_MONTH); | ||
|
||
return new DatePickerDialog(getActivity(), this, year, month, day); | ||
} | ||
|
||
@Override | ||
public void onDateSet(DatePicker datePicker, int year, int month, int day) { | ||
((MainActivity) getActivity()).setLocalDate(new Date(year - 1900, month, day)); | ||
} | ||
} |