1. Check out our companion app, Forums for Android! Download from Google Play

Change Date from Variables

Discussion in 'Application Development' started by Duny, Jun 12, 2010.

  1. Duny

    Duny New Member
    Thread Starter
    5

    Jun 6, 2010
    2
    0
    5
    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 (Text):
    1.  
    2.     final Calendar c = Calendar.getInstance();
    3.     mYear = c.get(Calendar.YEAR);
    4.     mMonth = c.get(Calendar.MONTH);
    5.     mDay = c.get(Calendar.DAY_OF_MONTH);
    6.     jDay = c.get(Calendar.DAY_OF_YEAR);
    7.  
    8.     // display the current date (this method is below)
    9.     updateDisplay();
    10. }
    11. private void updateDisplay() {
    12.     mDateDisplay.setText(
    13.         new StringBuilder()
    14.                 // Month is 0 based so add 1
    15.                 .append(jDay));
    16. private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
    17.  
    18.             public void onDateSet(DatePicker view, int year,
    19.                                   int monthOfYear, int dayOfMonth) {
    20.                 mYear = year;
    21.                 mMonth = monthOfYear;
    22.                 mDay = dayOfMonth;
    23.                 jDay = 123;//need this to change, to get the values from mYear, mMonth and mDay to change the day of the year (jDay).
    24.                 updateDisplay();
    25.             }
    26.         };
    27.  
     

    Advertisement

Share This Page

Loading...