• 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
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

confusing output of a date

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


output


why is it the program displays saturday???

please help me here....
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

eD.setExpirationDate(10, 1, 25);


It should be 2010, not 10. You should figure that out yourself by either debugging through your code, or adding some System.out.println around.
 
jhon max
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you sir.. i thought the Calendar class will only generate the last two digits of the current year.... thank you sir again!
 
jhon max
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the only thing that confuse me is that when i pass the number 10... and when i call the method getFullExpirationDate().. the compiler generates the year exactly
2010...
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

jhon max wrote:the only thing that confuse me is that when i pass the number 10... and when i call the method getFullExpirationDate().. the compiler generates the year exactly
2010...


Check what you are doing in getExpirationYearInNumber.
 
jhon max
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh sorry sir for not clearing the problem... what i mean is.. even if i pass a number 10.. the compiler generates the exact year.... im not reffering to the method
getExpirationYearInNUmber()...

The compiler is still reffering to this year....




output

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

im not reffering to the method getExpirationYearInNUmber()...


You are calling getExpirationYearInNUmber from getFullExpirationDate, so don't tell me you're not referring to it
 
jhon max
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry i cant express my thoughts too much.... i cant speak enough english very well ...
so i look my files and found this one...


if i enter 10 - year
01 - month
24 - day
the outut is


but if i enter


this is what make me confuse...
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Here, you call getFullExpirationDate(). In getFullExpirationDate(), you call getExpirationYearInNumber(). getExpirationYearInNumber() return a year, which always starts with "20". So even if start with setExpirationDate(10, 01, 24), when you call getFullExpirationDate(), the returned object's year will be 2010, not 10. You should ask yourself why you are using "20" in getExpirationYearInNumber().

 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Precisely, when you enter "10", its interpreted as "0010". Are you getting the point now?
 
jhon max
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

"10", its interpreted as "0010"



ahh so thats why im getting a wrong date... thats how the compiler generates the specified year.....
tnx!
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, precisely again . You can try that out yourself by giving 0010 as your input.
Cheers.
 
It's hard to fight evil. The little things, like a nice sandwich, really helps. Right tiny ad?
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic