Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomorrows date

 
Pam Theod
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have a need to get tomorrows date with time of 23.59 and check the date the user enters in the GUI is not > tomorrow midnight. How do I get tomorrows date.

Thanks in advance.

p
 
Martin Simons
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Then compare this Date object with the parsed Date object from the user.
How you parse the date from the user depends on how the user is to enter
the date.
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_MONTH, 1);
c.set(Calendar.HOUR, 23);
c.set(Calendar.MINUTE, 59);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
 
Paul Clapham
Sheriff
Posts: 21316
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be better to useOtherwise you get code that works differently in the afternoon and in the morning. This is coming from somebody who was personally burned by this feature.
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Woops you're right, don't want to get burned like that either.
 
Pam Theod
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to everyone! I have this working now.

P pro
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic