The Artima Developer Community
Sponsored Link

Java Answers Forum
Adjusting a Date object in Visual Age for Java

1 reply on 1 page. Most recent reply: Dec 3, 2002 11:39 AM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Terrence Vega

Posts: 1
Nickname: terryvega
Registered: Dec, 2002

Adjusting a Date object in Visual Age for Java Posted: Dec 3, 2002 10:40 AM
Reply to this message Reply
Advertisement
In my code I have many lines such as this:
java.util.Date myDate = new java.util.Date();
This sets myDate to the current processing date.

Without changing anything to this (as there are far too many lines to change), I wish to set every new Date instantiation to a date in the past, such as half a year ago.

Is anyone upto the challenge?

P.S. If I go to the java API code in VAJ, it says I cannot modify the return value of the Date.


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Adjusting a Date object in Visual Age for Java Posted: Dec 3, 2002 11:39 AM
Reply to this message Reply
Here are a couple ideas:

- Change your computer's date back six months and run the program! ;-)

- Okay, this one is a little better: First, change every place where you have "new java.util.Date();" to "getADate();" (or whatever method name you prefer). This should be an easy search-and-replace operation with your editor, or sed, or whatever. In this new method, get the current date, modify it as necessary (or create another one based on it) and return the tweaked date.

If this needs to be done across classes, you may need a helper object to host the method and your original replacement above might be something along the lines of replacing "new java.util.Date();" with "com.myfirm.utils.FakeDate.getInstance().getTweakedDate();".

Flat View: This topic has 1 reply on 1 page
Topic: Applet destroying Previous Topic   Next Topic Topic: cannot resolve symbol: variable

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use