• Post Reply Bookmark Topic Watch Topic
  • New Topic

confusing output of a date  RSS feed

 
jhon max
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


output


why is it the program displays saturday???

please help me here....
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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().

 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Yes, precisely again . You can try that out yourself by giving 0010 as your input.
Cheers.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!