wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Dates as String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Dates as String" Watch "Dates as String" New topic
Author

Dates as String

mike molin
Greenhorn

Joined: Nov 11, 2010
Posts: 17
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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

[My Blog]
All roads lead to JavaRanch
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

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


Mohamed Sanaulla | My Blog
mike molin
Greenhorn

Joined: Nov 11, 2010
Posts: 17
yes its homework i can get the first date, but the second date is harder
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

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

Joined: Nov 11, 2010
Posts: 17
problem solved thanks
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Don't expect us to do your own homework It's cool that you found the answer yourself.
 
 
subject: Dates as String
 
Similar Threads
Time Difference
how to find how many sundays comes in 2 Dates
How to Compare two Calendar Objects.
difference between two dates
Set holding two dates