Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Change the Date
- Loading branch information
1 parent
7c5f9d6
commit 551db67
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
app/src/main/java/dragosholban/com/timezoneconverter/DatePickerFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters