This code will not always calculate a 'nextDate' that is precisely one week prior to 'date' because it uses the naive assumprion that every day is 24 hours long. (Don't feel bad. A few years ago I worked on a major tax-calculation system that had the same bug. Consequently it miscalculated certain past-due conditions.)
The is also superfluously calling 'getTime()' on the 'Date' instances. This requires not only the extra call to 'getTime()' but autoboxing the result into 'Long'. Better to leave that invocation off. -- Lew On Friday, October 21, 2011 2:32:53 AM UTC-7, midhunvp wrote: > > you can try this . It will work. > > fd = (EditText) findViewById(R.id.from_date);a > td = (EditText) findViewById(R.id.to_date); > int MILLIS_IN_DAY = 1000 * 60 * 60 * 24; > Date date = new Date(); > SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); > String frommdate = dateFormat.format(date.getTime()); > String nextDate = dateFormat.format(date.getTime() - 7 > * (MILLIS_IN_DAY)); > fd.setText(nextDate); > td.setText(frommdate); > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en