• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

date

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how do i get the dates of the days seven days before the actual date?e.g.like today is 4th march,i would like to get 3rd march,2nd march,1st march,31st january,30th january,29th january,28th january.using java code
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is one of the probable solutions, there might be better approaches too.

 
Rancher
Posts: 425
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

daisy kagia wrote:how do i get the dates of the days seven days before the actual date?e.g.like today is 4th march,i would like to get 3rd march,2nd march,1st march,31st january,30th january,29th january,28th january.using java code


What do you mean by "the actual date"? If it's the current date, one of the ways to get that using System.currentTimeMillis(). You can also make use of the java.util.Calender class.
 
Pushkar Choudhary
Rancher
Posts: 425
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Swastik,
We do not encourage giving ready made solutions. DontBeACodeMill.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My apologies for the same.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing UI related here. Moving thread.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Swastik, your solution has a bug: it isn't daylight savings proof. A day does not always have 24 hours; when switching from winter time to summer time it's 23 hours and when switching from summer time to winter time it's 25 hours.

It's better to use class Calendar's date arithmetic methods, which take daylight savings into account. And you can use SimpleDateFormat to format dates, which is more convenient than doing it yourself with a StringBuffer.

 
reply
    Bookmark Topic Watch Topic
  • New Topic