Change Date from Variables


Last Updated:

  1. Duny

    Duny New Member This Topic's Starter

    Joined:
    Jun 6, 2010
    Messages:
    2
    Likes Received:
    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 (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...