gibboda wrote On 02/14/07 09:16,:
> I am trying to determine what is the best way to calculate a date
> using Calendar or Date java class. Searched the user group but did
[quoted text clipped - 14 lines]
> looking if the Java Calendar Class is not the appropiate course of
> action.
static Date dateFromDayCount(int daysSinceEpoch) {
Calendar when = new GregorianCalendar(
1967, Calendar.DECEMBER, 31);
when.add(Calendar.DAY_OF_YEAR, daysSinceEpoch);
return when.getTime();
}
Depending on exactly what you mean by "days from an epoch
of ...," you might need to start the Calendar from 1-Jan-1968
instead of from 31-Dec-1967. Find out what "zero days since
the epoch" is supposed to mean, and initialize the Calendar
to that date.
If the "epoch" is defined in terms of a particular time
zone (e.g., GMT or UTC), you should set up the Calendar to
use that zone. The code above uses the default local time
zone, meaning that the returned Date depends on the locale
as well as on the count of elapsed days.

Signature
Eric.Sosman@sun.com
gibboda - 16 Feb 2007 14:37 GMT
> gibbodawrote On 02/14/07 09:16,:
>
[quoted text clipped - 40 lines]
>
> - Show quoted text -
Thank you. I will try this out and I will keep in mind the zero day
question. The challenge I am faced with this database is I am using
the tool recommended by the company to pull data out, as I mention ran
into one little problem. The tool pulls the exact data from this
particular date field as number of days. I determine that the screens
this system uses converts the number of days into human readable dates
when viewing. It was a challenged to find out the exact epoch date
since there is no exact documenation on that date because I know most
systems have an epoch of Janaury 1, 1970 date but when I was trying to
calculate the date, I keep being off by 3 years and 1 day once I
determined it was not milliseconds but days. Now thinking about what
you said about zero date, I just tested a query run to pull only those
with January 1, 1968 which gave me the date to be 1. And December 31,
1967 gave me the date to be zero. Again thank you.