5 Replies Latest reply: Apr 18, 2007 9:06 PM by 807606

# Convert given integer to date.

A friend of mine helped my with the first method getYear(). I need another method that will give me the day and month from a given number.

public int getYear() {
int year = 0 ;
int numericDate = integerDate ;

for ( year = 1900; numericDate > ( isLeapYear(year) ? 366 : 365 ); year++)
numericDate -= ( isLeapYear(year) ? 366 : 365 ) ;

return year ;
}

public int getMonth() {
}

public int getDay() {
}
• ###### 1. Re: Convert given integer to date.
What is the "number" supposed to be?
• ###### 2. Re: Convert given integer to date.
What is the "number" supposed to be?
Don't tell us. It's more challenging when we have no idea what your specs are.
• ###### 3. Re: Convert given integer to date.
I've never regretted losing that "Gregorian date from Mayan Long Count digits" code so much as now.
• ###### 4. Re: Convert given integer to date.
Isn't there an urban legend about the Mayan calendar coming to an end in 2012,
and so an end to the world? Oh yes, my favourite web site: http://www.armageddononline.org/mayan_calendar.php
• ###### 5. Re: Convert given integer to date.
I am sorry for not being more specific.. basically this method returns the year from a given number. The base date is 01/01/1900. How would I go about developing another two different methods.. one that returns the day and the other that returns the month.

What I want to do is separate year, month, and day from a given number/integer. Example:
public int getYear() {
int year = 0 ;
int numericDate = integerDate ;

for ( year = 1900; numericDate > ( isLeapYear(year) ? 366 : 365 ); year++)
numericDate -= ( isLeapYear(year) ? 366 : 365 ) ;

return year ;
}
If the given number was 366 then the method will return the number "1" which is 01/01/1901.