View Single Post
  #2 (permalink)  
Old 05-07-2008, 09:24 AM
sanjeevtarar's Avatar
sanjeevtarar sanjeevtarar is offline
Senior Member
 
Join Date: Apr 2008
Location: Delhi(India)
Posts: 249
sanjeevtarar is on a distinguished road
Quote:
Originally Posted by jon80 View Post
Any idea how to resolve this?


import java.util.*;
public class DateLib {

private final long DAYS_TO_HOURS = 24L;
private final long HOURS_TO_MINUTES = 60L;
private final long MINUTES_TO_SECONDS = 60L;
private final long SECONDS_TO_MILLISECONDS = 1000L;

public static long getMillisecondsFromEpoch (int aYear, int aMonth, int aDay) {
/*
* Epoch is January 1, 1970 00:00.00 000 GMT
*/
//TODO calculate no of Years to milliseconds
final long Year = (((long) aYear) - 1970L);

if (!(isLeapYear)) { // HERE YOU ARE NOT CALLING THE METHOD
// ERROR: Exception in thread "main" java.lang.Error: Unresolved compilation //problem: isLeapYear cannot be resolved

}
else {

}

return Year;
}

public static long getMillisecondsFromEpoch (int aYear, int aMonth, int aDay,
int aHour, int aMinute, int aSecond)
{
/* TODO **
* Epoch is January 1, 1970 00:00.00 000 GMT
*/
return 0L;

}

private boolean isLeapYear (int aYear) {
/*
* if year modulo 400 is 0 then leap
* else if year modulo 100 is 0 then no_leap
* else if year modulo 4 is 0 then leap
* else no_leap
* (Source: Leap year - Wikipedia, the free encyclopedia)
*/

if ((aYear % 400) == 0) {return true;}
else if ((aYear % 100) == 0) {return false;}
else if ((aYear % 4) == 0) {return true;}
else {return false;}
}

}
see your code again and analyze it.

Where you defined the isLeapYear variable.....

and mark the isLeapYear method as static if you want to call it from static method
__________________
sanjeev,संजीव
Reply With Quote