Time Differences between linux & windows in my Java App
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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?
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?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.