Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Beginning Java
dates
David Jon
Greenhorn
Posts: 17
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
any one know how I can find out the date 7 days agoe? when the only object I have currently available is Date. essentially I want to do something like :
new Date() - 7days.
Any help appreciated.
Thanks,
DJ.
Art Metzer
Ranch Hand
Posts: 241
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi, David, let us know if this fills the bill?
<font size="2.0"> import java.util.*; public class AWeekAgo { public static void main( String[] args ) { Calendar cal = Calendar.getInstance(); Date today = new Date(); cal.setTime( today ); cal.add( Calendar.DATE, -7 ); Date weekAgo = cal.getTime(); System.out.println( "Now: " + today ); System.out.println( "One week ago: " + weekAgo ); } }
This code returned
<font size="2.0"> Now: Fri Apr 20 11:07:59 CDT 2001 One week ago: Fri Apr 13 11:07:59 CDT 2001
Art
David Jon
Greenhorn
Posts: 17
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
YOU ARE THE MAN
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Help Needed!!
Retrive Month and Year
BigDecimal to Date Conversion
getting first and last date of past 6 months?
yesterdays date
More...