LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-06-2006, 06:25 AM   #1
MRMadhav
Member
 
Registered: Nov 2005
Location: Mauritius
Distribution: PCQLinux, SUSE Linux,Fedora Core 5, Fedora Core 6, Knoppix Live, Kubuntu Edgy, PCLinuxOS
Posts: 167

Rep: Reputation: 30
Exclamation Time Differences between linux & windows in my Java App


Hi everybody!
I am getting a big problem in java. I have a client computer in windows and a linux server. No my problem is that when i run the same application in linux and in linux there seem to be a problem with the time. In windows the time is 1 hour backwards. E.g.

if the my windows sytem time is 13:15:20
the java app returns 12:15:20

but i don't get this problem when running in linux, the time is displayed correctly.

Here is my code:
Code:
//TimeTest.java
import java.awt.*;
import java.sql.*;

public class TimeTest
{
    public static void main(String[] args)
    {
         Time t = new Time(System.currentTimeMillis());
         System.out.println("Current Time is "+t.toString());
    }
}
As you can see I am using java.sql.Time which is convinient for portability to MySQL.
Does someone knows how to correct this problem?

Last edited by MRMadhav; 05-06-2006 at 06:31 AM.
 
Old 05-06-2006, 07:58 AM   #2
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
Is your timezone configured correctly? Does the time looks ok in linux(the clock in gnome or kde)?
 
Old 05-08-2006, 03:19 AM   #3
MRMadhav
Member
 
Registered: Nov 2005
Location: Mauritius
Distribution: PCQLinux, SUSE Linux,Fedora Core 5, Fedora Core 6, Knoppix Live, Kubuntu Edgy, PCLinuxOS
Posts: 167

Original Poster
Rep: Reputation: 30
Unhappy

Sorry I made a typing mistake in my first post should have said:
Quote:
my problem is that when i run the same application in linux and in windows, the time is different though the timezone and time is the same in both machines.
In linux the time is ok. My timezone is indian/mauritius and i don't use UTC. The problem is with windows, over here the timezone is +4GMT and daylight savings is enabled(Though i have tried all the other timezones and also tried without the daylight savings). The problem is that in windows the time displayed in my java app is always 1hr less than the system time. This would not have been a problem but as i use Auditing in my applications this 1hr lag can cause much problems. Didn't anyone get this type of problem before?
 
Old 05-08-2006, 01:22 PM   #4
thermite_1033
Member
 
Registered: May 2004
Location: Antwerp, Belgium
Distribution: slackware
Posts: 112

Rep: Reputation: 18
use the time of the sql server instead
you're just auditing so this will suffice

insert into audit(timeOfDay,auditmessage) value(now(),'barfoo');
 
Old 05-09-2006, 04:21 AM   #5
MRMadhav
Member
 
Registered: Nov 2005
Location: Mauritius
Distribution: PCQLinux, SUSE Linux,Fedora Core 5, Fedora Core 6, Knoppix Live, Kubuntu Edgy, PCLinuxOS
Posts: 167

Original Poster
Rep: Reputation: 30
Ok thanks for your help! That's a very useful feature in MySQL which i didn't even know existed!
 
  


Reply

Tags
time


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
time differences between windows and linux twantrd Linux - General 3 04-25-2006 08:49 AM
windows java based app running on fedora core 3? linuxmandrake Linux - Software 2 06-18-2005 12:10 PM
Ways To Run Windows & Linux Same Time megadeth Linux - Software 1 03-13-2005 06:45 PM
Perl: differences between Win2k & Linux? stoney79 Programming 2 01-13-2005 09:56 AM
Linux Vs. Windows.....what are the differences??? arctic123 General 40 09-28-2004 09:15 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration