Date: Tue, 25 Apr 2000 13:51:03 -0400 From: Rob Furphy <rcf@ox.com> To: freebsd-java@freebsd.org Subject: Time - is it right? Message-ID: <3905DB07.D847E037@ox.com>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Hi,
I've got a native freebsd jdk1.2.2 built using
FreeBSD 3.4 RELEASE (not STABLE)
gcc 2.7.2.3 (not 2.95.2)
lesstif 0.89.4 (not 0.89.9)
GNU make 3.77 (not 3.78.1)
GNU m4 1.4
dgs 0.5.8 (not 0.5.9)
unixODBC 1.8.7
I am happy to report initial success in a number of areas. Multicast
sockets work correctly. Database access is good.
The build is only about an hour old so I haven't tested alot yet but I
find that GregorianCalendar
and Date are not working correctly.
It seems the problem is in the TimeZone class or in what the TimeZone
class relies upon. I've attached a small
java program to demonstrate. Basically the default time zone under the
native freebsd jdk comes out as 'Custom'
and under the Linux RC4 the TimeZone is correct. Is this an issue with
my system/build or are other people seeing this?
Thanks to all for this port. I see good things ahead...
Rob F
[-- Attachment #2 --]
/*
When run under the Linux RC4 JDK I get the expected result and the correct time.
Under the FreeBSD native port I seem to be getting GMT time, reported as 'Custom'
in the GregorianCalendar.toString(). Daylight savings is also wrong but I suspect
that is because the timezone is incorrect
*/
import java.util.*;
public class foo {
public foo(String args[]) {
}
static public void main(String args[]) {
foo me = new foo(args);
me.doIt();
System.exit(0);
}
private void doIt() {
System.out.println(getHHMMSS(new GregorianCalendar()));
System.out.println(getHHMMSS(new GregorianCalendar(TimeZone.getDefault())));
System.out.println(new Date().toString());
System.out.println("\n" + new GregorianCalendar().toString());
}
private String getHHMMSS(GregorianCalendar now) {
int hours = now.get(Calendar.HOUR_OF_DAY);
if(hours > 12) {
hours -= 12;
}
int mins = now.get(Calendar.MINUTE);
int secs = now.get(Calendar.SECOND);
String ampm = (now.get(Calendar.AM_PM) == Calendar.AM) ? "am" : "pm";
return timeString(hours, mins, secs) + ampm;
}
private String timeString(int hour, int minute, int sec) {
String answer = "" + hour + ":";
if(minute < 10) {
answer += "0";
}
answer += minute + ":";
if(sec < 10) {
answer += "0";
}
answer += sec;
return answer;
}
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3905DB07.D847E037>
