• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

year conversion into days  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

The clarification i need is not JSP Related. But i never able to find the Forum for my clarification.

Problems:
i need to enter some vaues for Years like this 1.2 or 1(1.2 years or 1 year)
in my JSP, then i need to convert that date into no of days, i am doing that by multiplying 1.2 or 1*365 days, and after that i am using oracle function round to trim decimal values and based on no of days i am performing a search in oracle, to find some results.

but multiplying with 365 days, is not the correct way, because all years are not 365 days, so can anybody give me some knowledge, how to convert it into correct no of days to the year value i am passing.

please reply me , i am in very critical stage.

Regards,
Biswa Ranjan Mishra
 
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only way that requirement is going to work is if you know the year from when your 1.2 years applies, since that way you can work out whether you are in a leap year or not. Do you know this?
 
brmishra mishra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i know , it is always a sysdate
 
brmishra mishra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi paul,
if you have any solution , please inform me...

i need your help..

regards,
biswa
 
Author and ninkuma
Marshal
Posts: 66823
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a JSP question, so this has been moved to Java in General (intermediate).
 
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forget about Java for a minute. Write out on paper the steps you would take to accomplish your goal if you didn't have a computer. How would you figure this out?

Once you've determined your algorithm, translating it to Java should be a breeze.
 
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure that 1.2 years is precise enough to even worry about leap years. With one decimal place you're only going to get a date within about 3.6525 days. Call the range 4 and your precision plus or minus 2. A day off for leap year is within tolerance.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Stan James:
I'm not sure that 1.2 years is precise enough to even worry about leap years. With one decimal place you're only going to get a date within about 3.6525 days. Call the range 4 and your precision plus or minus 2. A day off for leap year is within tolerance.



I think you are assuming that the number has only two significant digits. Maybe the original poster means 1.20000 which would probably be precise enough for the leap day to make a difference. In which case, I agree with Steve's comments above. you should forget about Java and computers. Try and figure out how you would do this by hand. If someone told you that the world ends 1.2500 years from today, how would you figure out how many days that is if you want to account for any possible leap years? What if it is 2.333 years from today? What about 5.0000 years? Using different examples like this should help you to see how to develop an algorithm to do accomplish your task.

Regards,

Layne
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!