Anyone?
On Sep 7, 5:58 pm, podoboq <[email protected]> wrote: > Hi all, > > I'm working on my first Android app and getting odd results while > using DateUtils.getRelativeTimeSpanString(). The first time the > method gets called it seems to work fine, returning a character > sequence such as "27 days ago". But the next time the method gets > called it always returns a character sequence that is the same as the > startDate, such as "Aug 12, 2009". This seems strange. > > The method can be written in one line, but I split it out to four > lines and put a break point on each line. I can step through line by > line and everything looks correct ("year", "month", "day", "startDate" > and "now" are appropriate values) until the timeSpan gets set, where > it suddenly returns the startDate instead of a span of x days. Is > this a bug in DateUtils.getRelativeTimeSpanString or, more likely, I > am just overlooking something simple. > > public CharSequence myTimeSpan(int year, int month, int day) > { > long startDate = new GregorianCalendar(year, month, day).getTime > ().getTime(); > long now = new GregorianCalendar().getTime().getTime(); > CharSequence timeSpan = DateUtils.getRelativeTimeSpanString > (startDate, now, DateUtils.DAY_IN_MILLIS); > return timeSpan; > > } > > thanks in advance. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" 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-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

