This week's book giveaways are in the Scala and Android forums.
We're giving away four copies each of Machine Learning Systems: Designs that scale and Xamarin in Action: Creating native cross-platform mobile apps and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hashtable of Dates  RSS feed

 
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I'm familiarizing mself with Dates and GregorianCalender and at the same time I'm trying to put them into a Hashtable, such that the previous date becomes the last coupon date i.e. prvCouponDate = lstCouponDate and the previous coupon date is recalculated by using the formula prvCouponDate.add(GregorianCalendar.MONTH,(-12/2)
But Java Console shows that my code didn't change the value of prvCouponDate at all. Here is the console output

system datetime stamp: Mar 16, 2004 10:54:17 PM
now: 01 Nov 1992
last coupon date: 15 Jan 1998
previous coupon date: 15 Jul 1997
*** last coupon date: 15 Jul 1997
*** previous coupon date: 15 Jul 1997
0: Thu Jan 15 00:00:00 CST 1998

And here is the offensive code snippet...

Why does this line of code prvCouponDate.add(GregorianCalendar.MONTH,-6) work once only? I would really like to know why Java behaves like this.
TIA :-)
 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am so sorry, please close this thread.
I made a spelling mistake.
Works after I corrected my spelling...
:-(
 
If you open the box, you will find Heisenberg strangling Shrodenger's cat. And waving this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!