?
Solved

6 hours off from current timestamp

Posted on 2003-02-28
10
Medium Priority
?
674 Views
Last Modified: 2008-01-16
Im using the following code and my time is off 6 hours from what the system clock is. Im on central time if that matters.  My question is, how do I get this to show the exact time it is currently vice 6 hours ahead????

Calendar cal = new GregorianCalendar();
SimpleDateFormat formatter1 = new SimpleDateFormat("yy_MM_dd_HH_mm_ss");
        String inputDate2 = formatter1.format(cal.getTime()) + "_000000";
0
Comment
Question by:TheVeee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 8042559
What does

System.out.println(cal.getTime());

produce?
0
 
LVL 5

Author Comment

by:TheVeee
ID: 8042815
Sorry, had to deploy this to mainframe...

Time was
cal.getTime(): Fri Feb 28 16:15:36 GMT 2003
and the actual time was 10:15 AM Central Standard Time
0
 
LVL 3

Expert Comment

by:allahabad
ID: 8043164
     SimpleDateFormat formatter1 = new SimpleDateFormat("yy_MM_dd_HH_mm_ss");
      Date currentDate = new Date();
      long time = currentDate.getTime()+6*60*60*1000; // add 6 hours in millisecond
      currentDate.setTime(time);
      String formatedDate = formatter1.format(currentDate);
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 86

Expert Comment

by:CEHJ
ID: 8043195
You're not going to like this, but you might have to reinstall the JRE! I'll check...
0
 
LVL 5

Author Comment

by:TheVeee
ID: 8043267
CEHJ,

My Websphere System guy thinks this is a global setting so it will read the uses default Profile.  The user profile usually has a TZ environment variable which tells the Timezone, subtract 6 hours and so forth.  He thinks that when the IBM Websphere is starting it isnt using that standard profile so he needs to see how IBM has compensated for this problem in the UNIX environment. I actually running this on a OS/390 Mainframe System (Websphere).
0
 
LVL 5

Expert Comment

by:vemul
ID: 8043287
>> cal.getTime(): Fri Feb 28 16:15:36 GMT 2003

as it says you are showing the GMT time. To convert it to different timezone, maybe CST, try changing the timezone and verifying it. Does the machine on which you program runs display time in GMT format?
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 8043304
Hmm. It would be interesting to see what passing "user.timezone" to the following program produces:

public class Props {

  public static void main(String[] args){
    if(args.length > 0){
     for(int i = 0;i < args.length;i++){
      System.out.println(System.getProperty(args[0]));
     }
    }
    else {
      System.getProperties().list(System.out);
    }
  }
}
0
 
LVL 5

Author Comment

by:TheVeee
ID: 8043493
CEHJ,

Thanks for the input.  Turns out called IBM and on the Mainframe System for each server there is a setting you have to put in the JVM.Properties file for that particuliar server.  The setting must be set to user.timezone=CST or user.timezone = CDT.  Then recycle server and WALA... it worked... By the way thanks for your time and I will give you the 50 points for researching...Thanks again, like usual!!
0
 
LVL 5

Author Comment

by:TheVeee
ID: 8043500
Thanks for the help... I think we both learned something on this.... Mainframe Java is tough!! Later!!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8043517
:-)
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question