Finally I got it.................. Thanks for ur support ....
On Fri, Sep 25, 2009 at 9:15 AM, ragavendran s <[email protected]>wrote: > I want to calculate the difference between two Dates......Can anybody tell > how to calculate the difference between two days.... > > Here is my Code....it Displays Calendar and it displays the Local Time > Zone........ > > Thanks in Advance... > > With regards, > > Raghav.S > > > > > > > public class datedisplay extends Activity { > private TextView mDateDisplay,dis; > private Button mPickDate; > > private int mYear; > private int mMonth; > private int mDay; > private float days; > > private long diff; > static final int DATE_DIALOG_ID = 0; > > @Override > protected void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > > // capture our View elements > mDateDisplay = (TextView) findViewById(R.id.dateDisplay); > mPickDate = (Button) findViewById(R.id.pickDate); > dis = (TextView) findViewById(R.id.dis); > // add a click listener to the button > mPickDate.setOnClickListener(new View.OnClickListener() { > public void onClick(View v) { > showDialog(DATE_DIALOG_ID); > } > }); > > // get the current date > final Calendar c = Calendar.getInstance(); > final Calendar c1=Calendar.getInstance(); > > > mYear = c.get(Calendar.YEAR); > mMonth = c.get(Calendar.MONTH); > mDay = c.get(Calendar.DAY_OF_MONTH); > > > // display the current date > updateDisplay(); > } > @Override > protected Dialog onCreateDialog(int id) { > switch (id) { > case DATE_DIALOG_ID: > return new DatePickerDialog(this,mDateSetListener,mYear, > mMonth, mDay); > } > return null; > } > private DatePickerDialog.OnDateSetListener mDateSetListener = > new DatePickerDialog.OnDateSetListener() { > > public void onDateSet(DatePicker view, int year, > int monthOfYear, int dayOfMonth) { > mYear = year; > mMonth = monthOfYear; > mDay = dayOfMonth; > updateDisplay(); > > } > }; > > private void updateDisplay() { > > mDateDisplay.setText( > new StringBuilder() > // Month is 0 based so add 1 > .append(mMonth + 1).append("-") > .append(mDay).append("-") > .append(mYear).append(" ")); > > > > } > > > > } > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

