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

Tomorrow's date

 
Md Fizal
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone gimme the piece of code in Java to get the tomorrow's date?
 
Juanjo Bazan
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try:

You can check the day with the Calendar.get(Calendar.DAY_OF_MONTH) method.
HTH
 
Chris Treglio
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah, but I don't think I can get to it today. Do you mind if I send it tomorrow?
hahahahajk.
I think you're looking for Calendar.roll(Calendar.DAY_OF_MONTH, true).
 
Md Fizal
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it. Thanks Juanjo and Chris
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead try
Calendar.add(Calendar.DATE, 1);
The difference is noticeable if the date is at the end of the month, like Jan 31. The roll() method will take you to Jan 1, while the add() method takes you to Feb 1.
 
Arun Boraiah
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this also.
Date dt = new Date(System.currentTimeMillis() + (24*60*60*1000) );
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fiz,
Please change your name to be compliant with JavaRanch's naming policy. It should not be obviously fictitious.
Your displayed name should be 2 separate names with more than 1 letter each. We really would prefer that you use your REAL name.
You can change your name: here.
Thanks,
Cindy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic