• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Change Date from Variables

Duny

Lurker
Jun 6, 2010
2
0
I am trying to get the Day_of_year from a Datepicker, works but I want to alsom change the day of the year, is there a function like in PHP to change the values.

Code:
    final Calendar c = Calendar.getInstance();
    mYear = c.get(Calendar.YEAR);
    mMonth = c.get(Calendar.MONTH);
    mDay = c.get(Calendar.DAY_OF_MONTH);
    jDay = c.get(Calendar.DAY_OF_YEAR);

    // display the current date (this method is below)
    updateDisplay();
}
private void updateDisplay() {
    mDateDisplay.setText(
        new StringBuilder()
                // Month is 0 based so add 1
                .append(jDay));
private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {

            public void onDateSet(DatePicker view, int year, 
                                  int monthOfYear, int dayOfMonth) {
                mYear = year;
                mMonth = monthOfYear;
                mDay = dayOfMonth;
                jDay = 123;//need this to change, to get the values from mYear, mMonth and mDay to change the day of the year (jDay).
                updateDisplay();
            }
        };
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones