Java Time in millisec

Hi,
This should be a simple thing to do in java but i have spent a lot of time without getting the desired result. I have a time in YYYY:MM:DD:hh:mm:ss format and I want to find the number of millisec since Jan 1 1970 (UTC time). I have tried to use the Calender class but its not giving the correct output
Calendar c = Calendar.getInstance();
c.set(2006, 6, 8, 10, 55, 00); // Today 10:55 am
System.out.println("Time is "+c.getTimeInMillis());
Can anyone help me with this.
Thanks.

Ok that was a dumb question. I should have figured
that out myself.
SimpleDateFormat simpledateformat = new
SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
System.out.println("SimpleDateFormat time is
"+simpledateformat.parse("2006-06-08-07-20-00").getTim
e());
Another Question: Will Date now = new Date(); take
care of daylight saving? What I am doing is
SimpleDateFormat formatter = new SimpleDateFormat(
"yyyyMMdd:HH:mm:ss");
formatter.setTimeZone( TimeZone.getTimeZone("GMT")
Date now = new Date();
formatter.format(now);
So will it automatically adjust with daylight
saving?GMT doesn't have DST.

Similar Messages

  • Java Time conversion

    Hi
    I know this must a simple thing to do in Java but I can't seem to find it.
    I need to convert UTC time in millisec into GMT regular time. i.e.
    1155000000000 should be converted to Tue Aug 8 01:20:00:000 GMT 2006
    Thnx

    Crossposted and answered:
    http://forum.java.sun.com/thread.jspa?threadID=759645&messageID=4337407#4337407
    Don't waste your time on this.

  • Java Timer problem

    hi,
    i am finding some problem using java timer.
    I have a server program that regularly needs to save its data. i want to do it using java Timer.
    i got the following sample code as an example. it works perfectly but how can i send new data each time to save?
    import java.util.Timer;
    import java.util.TimerTask;
    import Core.General;
    public class test_timer {
    public static void main(final String args[]) {
    final Timer timer = new Timer();
    timer.scheduleAtFixedRate(new ttask(), 3000, 3000);
    class ttask extends TimerTask
    public void run() {
    System.out.println("hello ");
    As an example i would like to send current time to the timer task and print it. how is it possible?
    regards
    tom

    For the current time you can just go ahead and do the following call:
    System.currentTimeMillis();
    This will get you the current time in milleseconds.
    When timer is called, get the crrent time and print it.
    Hope this helps.
    hi,
    i am finding some problem using java timer.
    I have a server program that regularly needs to save
    its data. i want to do it using java Timer.
    i got the following sample code as an example. it
    works perfectly but how can i send new data each time
    to save?
    import java.util.Timer;
    import java.util.TimerTask;
    import Core.General;
    public class test_timer {
    public static void main(final String args[]) {
    final Timer timer = new Timer();
    timer.scheduleAtFixedRate(new ttask(), 3000,
    000, 3000);
    class ttask extends TimerTask
    public void run() {
    System.out.println("hello ");
    As an example i would like to send current time to the
    timer task and print it. how is it possible?
    regards
    tom

  • Java 8: Pb with new java.time api

    Hello,
    I'm trying to use the new java.time api that comes with Java 8 (I already know joda-time).
    I'm using the latest build B124.
    I've a String "01/08/2012_00:00:01", I know that the time ref. is UTC, and I want to convert it to an 'Instant';
    I tried:
    DateTimeFormatter FORMAT_DT = DateTimeFormatter.ofPattern("dd/MM/yyyy_HH:mm:ss").withZone(ZoneOffset.UTC);
    Instant instant = Instant.from(FORMAT_DT.parse("01/08/2012_00:00:01"));
    But it fails with following error:
    java.time.DateTimeException: Unable to obtain Instant from TemporalAccessor: {},ISO resolved to 2012-08-01T00:00:01 of type java.time.format.Parsed
         at java.time.Instant.from(Unknown Source)
    I don't understand what's wrong with my code, and I can't figure out how I should proceed to convert the String to an Instant ...
    Any suggestion welcome,
    Best regards,
    Bernard.

    Originally you stated this:
    I don't understand what's wrong with my code,
    So naturally we focused on how to "understand what's wrong' with your code.
    You will never learn to troubleshoot problems if you just throw your hands up in the air and ask for help just because a complex series of steps doesn't complete successfully. 
    Break the process into its individual steps and check the results of each step to identify which step is FIRST producing an error.
    When a complex or multi-step process has an error you start checking the individual steps of the process to see how far it gets successfully.
    I would expect that converting a String to an Instant should be a basic/simple need, so it should be possible to do it in two lines of code; for the time being, the only way I found is to use a LocalDateTime intermediate variable, which seems quite verbose, and I'm wondering if someone knows a better way to do it, and would be willing to share it here.
    Just a technical distinction: your latest example using a LocalDateTime intermediate variable CAN be done in one line of code by just using dot-notation to avoid creating an explicit intermediate variable. But that variable will still be created implicitly behind the scenes.
    Converting a String to an Instant might be considered a basic/simple need but the set of functionality related to dealing with times, dates, calendars, etc is extremely complex. It makes much more sense to develop the requisite functionality in modules.
    Especially when introducing new functionality such as the 'Instant' class are related package elements introduced in 1.8. That functionality builds on what came before and parsers already existing that know how to deal with all of the possible String variants and formatting options and so on.
    Since that work CAN BE done on-the-fly using dot notation and anonymous implicit intermediate classes there isn't much need to reinvent that functionality in the new classes. If certain uses become standard new methods can always be added (e.g. to the Instant class) that will 'appear' to do things in one step.
    And, being an early adopter release, you can always file a 'bug' or enhancement request from the 1.8 download page. That page has links for 'Report Bugs' and 'Feedback forum' that you can use.
    In this current forum no one can give you an 'official' answer as to why something was implemented a particular way and/or whether that implementation is a 'bug' or was designed to work that way. Only Oracle can do that.

  • Using java.time.LocalDate class

    Hello,
    I am using the latest JDK8 build b87 and JDeveloper 11.1.2.1. In the editor, the code insight does not show the java.time.LocalDate class. When I use the LocalDate class, it is highlighted in red. However, I can compile and run the application fine. Other classes in the java.time package, for example, the Clock class is fine. I can use classes from the java.time subpackages fine. How can I fix this issue?
    Thanks
    Kishori

    JDeveloper does not support JDK 8 as indicated by the certification matrix.
    http://www.oracle.com/technetwork/developer-tools/jdev/index-091111.html
    java.time.LocalDate being a new class, code insight does not support the class.

  • Look-up java time zone based on location?

    I have a test app where I can assign a java timezone and return time info - However, I don't see a way to look-up a java time zone based on location (combination of city/province/state/country).
    Is this possible?

    Has any one found a way to lookup a timezone based on a city/region in the world? So one could be able to type any city and state/province and country combination and get the corresponding timezone for that region. Is there a place where one can buy this data?
    Thank you

  • Tomcat Restart and Java Timer

    I have used Java Timer class to schedule a report to be generated during midnight. It works fine if i do not stop Tomcat, but when i stop and restart Tomcat server the Timer job seems to be lost and it doesn't run during the midnight. Any ideas how to resolve this issue? I thought timer's would be persistent...Thanks.

    So it should be web-based....is there a way??1. Never shut down the web server.
    2. [Deleted]
    3. Create your own report server (standalone application) and create a web-based application to interact with the report server (standalone application) and send it the query.
    In the third option, you can start and stop the web server all you want. The report server will continue running. The report server will only fail to respond to requests if the machine (node) is turned off or if there is a bug.

  • Use Java Timer to move a panel smoothly, need help!

    I am using JBuilder to build an Windows Application.
    I put everything on the contentPane. There is one Panel I call it "jPanelDemo" and another panel "jPanelText".
    Now I want to start a timer, and move jPanelDemo panel from the right side of jPanelText to the same location of jPanelText, when the timer stops, jPanelDemo should place the jPanelText position.
    Here is my code:
    // declare the timer
      Timer timer1 = new Timer(1000,null);
      int timerSpeed = 1;
    // here is the ActionListener
        timer1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
           while (jPanelDemo.getLocation().x > jPanelText.getLocation().x)
             jPanelDemo.setLocation(jPanelDemo.getLocation().x - timerSpeed, jPanelDemo.getLocation().y);
             contentPane.repaint();
             jPanelDemo.repaint();
           timer1.stop();
    // here to ensure jPanelDemo replaced jPanelText
    jPanelDemo.setLocation(jPanelText.getLocation().x, jPanelDemo.getLocation().y);
       );The timer is triggered by clicking a certain Jbutton.
    I did the similar codeing in .NET programming and it worked fine. However, I translate the code to Java. When I run this code, the timer actually works, and jPanelDemo does move and replace the jPanelText.
    The problem I am facing now is: when I start the timer, the movement of jPanelDemo cannot be seen, until the timer stopped, the jPanelDemo poped up at the same location of jPanelText.
    I tried to use contentPane.repaint(), it doesn't work for me.
    Please help me solve this problem.

    I do not quite understand what you mean.
    I added the ActionListener when I initialize the
    controls while the frame is loaded.Yes I missed that but you still have a loop in the event thread which is a NO NO. Maybe this will illustrate AN approach -
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Fred702 extends JPanel
        public Fred702()
            super(null);
            setPreferredSize(new Dimension(640, 480));
            final JLabel label = new JLabel("Hello");
            add(label);
            final int deltaT = 50;
            new javax.swing.Timer(deltaT, new ActionListener()
                double theta = 0.0;
                double deltaTheta = 0.2 * Math.PI * deltaT / 1000.0;
                int r = 200;
                public void actionPerformed(ActionEvent e)
                    int x = (int)(Math.sin(theta) * r + 0.5 + r);
                    int y = (int)(Math.cos(theta) * r + 0.5 + r);
                    label.setBounds(x, y, label.getPreferredSize().width, label.getPreferredSize().height);
                    theta += deltaTheta;
            }).start();
        public static void main(String[] args)
            JFrame frame = new JFrame("Fred702");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setContentPane(new Fred702());
            frame.pack();
            frame.setVisible(true);
    }

  • How to stop the java timer

    I tried writing a program for a scheduler using java , compiled and ran in java 1.6 .The code is given below
    import java.util.*;
    public class TimerTaskEx2 {
         public static void main(String[] args) {
              Timer timer = new Timer();
              timer.scheduleAtFixedRate(new TimerTask(){
                   public void run() {
                        System.out.println("Java");
              }, 5000, 1000);
    output
    Java
    Java
    Java
    Java
    Java
    Java
    Java
    The output of this program starts after 5 milliseconds delay and keeps running infinitely becoz the program is written only in such a way .
    but my actual requirement is the timer should start 5 milliseconds after i run the program and stop after 20 milliseconds .
    Here I need to know how to stop it at a required time interval
    I dont find any api regarding this in 1.6 spec .
    please clarify how to do that .
    Thanks
    Jee

    try this code:
    import java.util.*;
    public class TimerTaskEx2 {
         public static void main(String[] args) {
              Timer timer = new Timer();
              timer.scheduleAtFixedRate(new TimerTask() {
                   int i = 0;               
                   public void run() {
                        System.out.println("Java");
                        i++;
                        if (i > 3)
                             this.cancel();                    
              }, 5000, 1000);
    Also, make sure to close the alive thread too.

  • Java time zone parameter has no affect.

    I am attempting to set the timezone on a single stack Java instance to match the time zone settings on our ERP EHP6 system. I set the parameter
    -Dusertimezone=CST and GMT-5 using the configuration manager, save the change and restart the JAVA stack.  Each time I restart the system I get the attached error in the default trace log and when I check system info page the timezone still shows as GMT. What is the proper abbreviation to use for US Central Time Zone.
    OS is Windows 2008 R2 with the timezone correctly set. The DB is Oracle 11.2.0.4 and SAP is netweaver 7.0 EHP1.
    Thank You in Advance
    Troy Sorbet
    The error is listed in the attached file, sorry I can't get text to paste into the note.
    This is the banner for the error message
    "The specified time zone is not found in SchedulerTime config class"

    See SAP KBA 1867012 for a list of valid values. That said the error is returned from the KM Scheduler service, meaning it isn't global. I assume your instance starts but only the KM Scheduler service doesn't start. If that's the case what is the SP level of your NW701 system? Applying SAP note 1675803 might solve your problem.

  • Java Time Counter / Date Class Question

    I am trying to make a program that if a input is recieved it will record the time and when another input is recieved it will record the time as well.
    I am sorry of stupid question:
    1. how do i minus both "timing"? i try to directly minus it, but doesn't seem to work .
    2. in the java Doc it say it can only take up to milli seconds. Is this the smallest time unit i could mesaure?

    I am trying to make a program that if a input is
    recieved it will record the time and when another
    input is recieved it will record the time as well.
    I am sorry of stupid question:
    1. how do i minus both "timing"? i try to directly
    minus it, but doesn't seem to work .
    2. in the java Doc it say it can only take up to milli
    seconds. Is this the smallest time unit i could
    mesaure?1.
    long start = System.currentTimeMillis();
    // do something
    long end = System.currentTimeMillis();
    long elapsed = end - start; //ms
    2.
    No there are smaller.
    Java Tiger (1.5) offers a nano unit for measuring issues.
    currentTimeMillis()
    Returns the current time in milliseconds.
    nanoTime()
    Returns the current value of the most precise available system timer, in nanoseconds.
    good luck!

  • Java time counter ?

    Hi,
    Is there anyway to set time counter on java?
    My friend suggested that I can use util.date at the begining of my program and use it again at the end, after compare these two value, I can get the time period of the program.
    However, since util.date will read the time from OS, if user set the OS clock back or forward, I cannot get accurate time.
    My program is really sensitive with time (I have to get exactly time the user uses my program.)
    Can anyone please have any suggestion about it?
    Thank you

    > The external class Clock from the javabook package can assist you in your quest.
    The internal class Timer from the java.util (or javax.swing) package can assist with his quest and doesn't require external libraries. If the user is interested in external libraries, I'd recommend the Commons Lang StopWatch* class, which is part of the Commons Lang library, which contains a wealth of useful classes.
    * http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/time/StopWatch.html
    ~

  • I need help with java Time Zone Updater for Venezuela Time Zone

    Hi,
    I've run the latest Time Zone Updater (1.3.5) on JRE 1.4.2. It is supposed to support the time zone changes for Venezuela. The problem is that when I set my Windows time zone and run java.util.TimeZone.getDefault() it says that I am on GMT instead of GMT-04:30.
    Am I doing something wrong?
    Thanks in advance for your help.

    I have found the solution for cases in which you cannot update your JRE to anything further than 1.5. You will have to create an extra entry in the Java tzmappings file as follows:
    Venezuela Standard Time:90,90::America/Caracas:After doing this, you will have to create a new String Value in your Windows registry for the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\Venezuela Standard Time Key as follows:
    Name: MapID
    Value: 90,90
    Best regards.

  • Frameaccess.java - time of presentation of each frame

    i've found frameaccess, which introduces a plugin in transcoding phase of processing.my question are, (i'm a newbie of jmf) it's possibile to modify in the code below the processor to have in shell display,time of presentation of each frame?another question is :it's possible to modify framerate and bit x pixel of output?
    thanks
    ////////////code
    * @(#)FrameAccess.java     1.5 01/03/13
    * Copyright (c) 1999-2001 Sun Microsystems, Inc. All Rights Reserved.
    * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
    * modify and redistribute this software in source and binary code form,
    * provided that i) this copyright notice and license appear on all copies of
    * the software; and ii) Licensee does not utilize the software in a manner
    * which is disparaging to Sun.
    * This software is provided "AS IS," without a warranty of any kind. ALL
    * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
    * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
    * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
    * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
    * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
    * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
    * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
    * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
    * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
    * POSSIBILITY OF SUCH DAMAGES.
    * This software is not designed or intended for use in on-line control of
    * aircraft, air traffic, aircraft navigation or aircraft communications; or in
    * the design, construction, operation or maintenance of any nuclear
    * facility. Licensee represents and warrants that it will not use or
    * redistribute the Software for such purposes.
    import java.awt.*;
    import javax.media.*;
    import javax.media.control.TrackControl;
    import javax.media.Format;
    import javax.media.format.*;
    * Sample program to access individual video frames by using a
    * "pass-thru" codec. The codec is inserted into the data flow
    * path. As data pass through this codec, a callback is invoked
    * for each frame of video data.
    public class FrameAccess extends Frame implements ControllerListener {
    Processor p;
    Object waitSync = new Object();
    boolean stateTransitionOK = true;
    * Given a media locator, create a processor and use that processor
    * as a player to playback the media.
    * During the processor's Configured state, two "pass-thru" codecs,
    * PreAccessCodec and PostAccessCodec, are set on the video track.
    * These codecs are used to get access to individual video frames
    * of the media.
    * Much of the code is just standard code to present media in JMF.
    public boolean open(MediaLocator ml) {
         try {
         p = Manager.createProcessor(ml);
         } catch (Exception e) {
         System.err.println("Failed to create a processor from the given url: " + e);
         return false;
         p.addControllerListener(this);
         // Put the Processor into configured state.
         p.configure();
         if (!waitForState(p.Configured)) {
         System.err.println("Failed to configure the processor.");
         return false;
         // So I can use it as a player.
         p.setContentDescriptor(null);
         // Obtain the track controls.
         TrackControl tc[] = p.getTrackControls();
         if (tc == null) {
         System.err.println("Failed to obtain track controls from the processor.");
         return false;
         // Search for the track control for the video track.
         TrackControl videoTrack = null;
         for (int i = 0; i < tc.length; i++) {
         if (tc.getFormat() instanceof VideoFormat) {
              videoTrack = tc[i];
              break;
         if (videoTrack == null) {
         System.err.println("The input media does not contain a video track.");
         return false;
         System.err.println("Video format: " + videoTrack.getFormat());
         // Instantiate and set the frame access codec to the data flow path.
         try {
         Codec codec[] = { new PreAccessCodec(),
                        new PostAccessCodec()};
         videoTrack.setCodecChain(codec);
         } catch (UnsupportedPlugInException e) {
         System.err.println("The process does not support effects.");
         // Realize the processor.
         p.prefetch();
         if (!waitForState(p.Prefetched)) {
         System.err.println("Failed to realize the processor.");
         return false;
         // Display the visual & control component if there's one.
         setLayout(new BorderLayout());
         Component cc;
         Component vc;
         if ((vc = p.getVisualComponent()) != null) {
         add("Center", vc);
         if ((cc = p.getControlPanelComponent()) != null) {
         add("South", cc);
         // Start the processor.
         p.start();
         setVisible(true);
         return true;
    public void addNotify() {
         super.addNotify();
         pack();
    * Block until the processor has transitioned to the given state.
    * Return false if the transition failed.
    boolean waitForState(int state) {
         synchronized (waitSync) {
         try {
              while (p.getState() != state && stateTransitionOK)
              waitSync.wait();
         } catch (Exception e) {}
         return stateTransitionOK;
    * Controller Listener.
    public void controllerUpdate(ControllerEvent evt) {
         if (evt instanceof ConfigureCompleteEvent ||
         evt instanceof RealizeCompleteEvent ||
         evt instanceof PrefetchCompleteEvent) {
         synchronized (waitSync) {
              stateTransitionOK = true;
              waitSync.notifyAll();
         } else if (evt instanceof ResourceUnavailableEvent) {
         synchronized (waitSync) {
              stateTransitionOK = false;
              waitSync.notifyAll();
         } else if (evt instanceof EndOfMediaEvent) {
         p.close();
         System.exit(0);
    * Main program
    public static void main(String [] args) {
         if (args.length == 0) {
         prUsage();
         System.exit(0);
         String url = args[0];
         if (url.indexOf(":") < 0) {
         prUsage();
         System.exit(0);
         MediaLocator ml;
         if ((ml = new MediaLocator(url)) == null) {
         System.err.println("Cannot build media locator from: " + url);
         System.exit(0);
         FrameAccess fa = new FrameAccess();
         if (!fa.open(ml))
         System.exit(0);
    static void prUsage() {
         System.err.println("Usage: java FrameAccess <url>");
    * Inner class.
    * A pass-through codec to access to individual frames.
    public class PreAccessCodec implements Codec {
    * Callback to access individual video frames.
         void accessFrame(Buffer frame) {
         // For demo, we'll just print out the frame #, time &
         // data length.
         long t = (long)(frame.getTimeStamp()/10000000f);
         System.err.println("Pre: frame #: " + frame.getSequenceNumber() +
                   ", time: " + ((float)t)/100f +
                   ", len: " + frame.getLength());
         * The code for a pass through codec.
         // We'll advertize as supporting all video formats.
         protected Format supportedIns[] = new Format [] {
         new VideoFormat(null)
         // We'll advertize as supporting all video formats.
         protected Format supportedOuts[] = new Format [] {
         new VideoFormat(null)
         Format input = null, output = null;
         public String getName() {
         return "Pre-Access Codec";
         // No op.
    public void open() {
         // No op.
         public void close() {
         // No op.
         public void reset() {
         public Format [] getSupportedInputFormats() {
         return supportedIns;
         public Format [] getSupportedOutputFormats(Format in) {
         if (in == null)
              return supportedOuts;
         else {
              // If an input format is given, we use that input format
              // as the output since we are not modifying the bit stream
              // at all.
              Format outs[] = new Format[1];
              outs[0] = in;
              return outs;
         public Format setInputFormat(Format format) {
         input = format;
         return input;
         public Format setOutputFormat(Format format) {
         output = format;
         return output;
         public int process(Buffer in, Buffer out) {
         // This is the "Callback" to access individual frames.
         accessFrame(in);
         // Swap the data between the input & output.
         Object data = in.getData();
         in.setData(out.getData());
         out.setData(data);
         // Copy the input attributes to the output
         out.setFormat(in.getFormat());
         out.setLength(in.getLength());
         out.setOffset(in.getOffset());
         return BUFFER_PROCESSED_OK;
         public Object[] getControls() {
         return new Object[0];
         public Object getControl(String type) {
         return null;
    public class PostAccessCodec extends PreAccessCodec {
         // We'll advertize as supporting all video formats.
         public PostAccessCodec() {
         supportedIns = new Format [] {
              new RGBFormat()
    * Callback to access individual video frames.
         void accessFrame(Buffer frame) {
         // For demo, we'll just print out the frame #, time &
         // data length.
         long t = (long)(frame.getTimeStamp()/10000000f);
         System.err.println("Post: frame #: " + frame.getSequenceNumber() +
                   ", time: " + ((float)t)/100f +
                   ", len: " + frame.getLength());
         public String getName() {
         return "Post-Access Codec";

    Alternatives to iPhoto's slideshow include:
    PhotoToMovie  $49.95
    PulpMotion  $129
    FotoMagico $99
    Final Cut Pro X $299
    It's difficult to compare these apps. They have differences in capability - some are driven off templates. some aren't. Some have a wider variety of transitions. Others will have excellent audio controls. It's worth checking them out to see what meets your needs. However, there is no doubt that Final Cut Pro X is the most capable app of them all. You get what you pay for.

  • Oracle/Java Time Discrepancy

    I have an Oracle procedure that rebuilds the index and a java application that calls the procedure. I don’t pass any timestamp at all, I just tell it to start and how long (approx) to run and then post the results in the GUI. When I run the procedure in the Oracle SQL Developer the start time is correct, however, when I run the same procedure though my Java Swing app the time stamp is 4 hours ahead of the current time. This confuses the users and is driving me nuts! The DB and the application are on one machine so there shouldnt be a time discrepancy. Any advice on how get Oracle to have the right time?
    For a test I ran the following code:
    public void retrieveTimeZone()
    String query = "select to_char(current_timestamp, 'dd Mon yyyy hh24:mi:ss') from dual";
    CallableStatement cs = null;
    ResultSet rs = null ;
    logMonitorList = new ArrayList();//reset list
    TimeZone tZone = TimeZone.getDefault();
    System.out.println("Java Date=" +new Date().toString());
    System.out.println("tZone=" +tZone.toString());
    try
    logger.logEvent(className, "retrieveTimeZone", "Query=" +query);
    cs = getDBConnection().prepareCall(query);
    rs = cs.executeQuery();
    while(rs.next())
    System.out.println("Oracle through Swing app time="+rs.getString(1));
    catch (SQLException e)
    logger.logEvent(className, "retrieveLogMonitor", e.toString());
    finally
    //close connections etc…
    The output is:
    Java Date=Thu Jun 12 17:18:57 EDT 2008
    tZone=sun.util.calendar.ZoneInfo[id="America/New_York",offset=-18000000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/New_York,offset=-18000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]
    Oracle through Swing app time=12 Jun 2008[b] 21:18:57

    Hi,
    I guess this is the same query with solution posted on: http://forum.java.sun.com/thread.jspa?threadID=5304867&tstart=60
    -Priyanka

Maybe you are looking for

  • How to resolve setPrefix() in SOAP(saaj API) with weblogic/webservices jar?

    Hi, I am facing a problem deploying a Web-Application in Weblogic containing SOAP related code. My environment is as below: 1) Weblogic 8.1 SP2 server 2) Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) 3) A method is exposed as

  • Index size bigger than table name? why?

    I have a table student_enrollwment_item_tbl with primary key "pk_stu_enroll_item" - STU_ENROLL_ID, TASK_ID, PART_ID, ITEM_ID. Table structure is as following: Name Null? Type STU_ENROLL_ID NOT NULL NUMBER ITEM_ID NOT NULL VARCHAR2(15) PART_ID NOT NUL

  • I purchased a 50$ gift card made a wish list and can't download

    i purcahsed a 50$ gift card redemmed it made a wish list but cannot purchase or download music

  • Multiple address of same vendor

    Dear All, There are certain vendors which has multiple locations with different statutory information such as Stax No. etc. At present we are opening new vendor. But purchase departments facing problem during preparing POs (some time they are prepari

  • Performance Guidelines - Dashboards 4.0

    Hi, I know, through experience of Xcelsius 2008,  there are quite a few performance guiidelines to follow with regard to building your Dashboard in Xcelsius 2008 but are there any specifics ones we should adhere to with regards to Dashboards 4.0. Is