0

I'll take only two questions related to Android.

I would like to have answered, I'd greatly appreciate it.

1

When you convert to java Calender, why values ​​differ?

ex) year: 1967 month: 12 day: 31

Calendar calendar = Calendar.getInstance ();
calendar.set (Calendar.YEAR, year);
calendar.set (Calendar.MONTH, (month - 1));
calendar.set (Calendar.DATE, day);
calendar.set (Calendar.HOUR_OF_DAY, 0);
calendar.set (Calendar.MINUTE, 0);
calendar.set (Calendar.SECOND, 0);
calendar.set (Calendar.MILLISECOND, 0);

(Ver. 2.3x)

input: 1967-12-31 00:00 -> result: 1967-12-30 23:30 (X)

input: 1968-10-01 00:00 -> result: 1968-09-30 23:30 (X)

input: 1968-10-02 00:00 -> result: 1968-10-02 00:00 (O)

In version 4.1.2, all values ​​match, there is no problem like that.

(Ver. 4.1.2)

input: 1967-12-31 00:00 -> result: 1967-12-31 00:00 (O)

input: 1968-10-01 00:00 -> result: 1968-10-01 00:00 (O)

input: 1968-10-02 00:00 -> result: 1968-10-02 00:00 (O)

2

When you select (hours or minutes) from the TimePicker*Dialog*, I do not want that the pop-up(keyboard input) is opened.

What should I do now?

I think that I would like you to answer to two questions.

Have a nice day. Thank you.

CoreJ
  • 11
  • 3

1 Answers1

0

Answer1: Values don't differ in my case, I am using DialogFragment here is my code:

public static class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the current date as the default date in the picker
        final Calendar c = Calendar.getInstance();
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);

        // Create a new instance of DatePickerDialog and return it
        return new DatePickerDialog(getActivity(), this, year, month, day);
    }

    public void onDateSet(DatePicker view, int year, int month, int day) {
        // Do something with the date chosen by the user

        Log.v(TAG,  "Year: " + year + " ,Month: "+ month + " ,Day: " + day );


    }
}

and this is the result: Year: 2014 ,Month: 1 ,Day: 25

the values are same for three versions of Android, ( 4.1.1, 4.4.2, 2.3.3 ) which I tested.

Sam
  • 546
  • 3
  • 16
  • First of all, I have the answer, thank you very much. Value of the data result of or after October 2, 1968 is the same for me. I think the problem is the value of the result of data Prior to October 1, 1968 and are different. I want, Disable keyboard input on Android TimePickerDialog. Thank you, Have a nice day. – CoreJ Feb 25 '14 at 01:48
  • please see this for hiding keyboard: http://stackoverflow.com/questions/1109022/close-hide-the-android-soft-keyboard – Sam Feb 25 '14 at 01:55
  • Thank you for the answer. – CoreJ Feb 26 '14 at 07:40