Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dates as String

 
mike molin
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have:

String date;
String date1;

must be Strings

1, How do you get date one to show the current date.
2. how do you get date1 to show the date 30 days from date,
3, the dates must be generated in some way, not just typed in from the keyboard.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this some kind of homework ?
Here are a few classes which will help you achieve this :
java.util.Date
java.util.Calendar
java.text.SimpleDateFormat
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out JavaDatesFaq. It has useful information. Also for showing Date 30 days ahead or 30 days behind- You can explore the Calendar class. Do check out its add() method
 
mike molin
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes its homework i can get the first date, but the second date is harder
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mike molin wrote:yes its homework i can get the first date, but the second date is harder

Calendar class is the one which will solve your problem
 
mike molin
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
problem solved thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't expect us to do your own homework It's cool that you found the answer yourself.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic