Java.sql.Time not working correctly

Hi guys,
I have the following code which is used to put clients session data in my database.
long logged_in_time = p.getCreatedTime();
            long logged_out_time = System.currentTimeMillis();
            long duration = logged_out_time - logged_in_time;
            System.out.println("LOGGED IN: " + logged_in_time);
            System.out.println("LOGGED OUT: " + logged_out_time);
            System.out.println("DURATION: " + duration);
            System.out.println("DURATION TIME: " + new Time(duration));and this is the result:
LOGGED IN: 1141394617474
LOGGED OUT: 1141394638634
DURATION: 21160
DURATION TIME: 01:00:21
Does anyone know why java.sql.Time adds an hour? The duration in milliseconds equals 21 seconds but when I constuct the Time obj I get 1 hour 21 seconds.
Any help would be great.
Alex

Probably because your default timezone is not GMT, but GMT+1 (e.g. CET.)
The java.util.Date (and subclasses) wraps a long value representing the number of miliseconds elapsed since January 1, 1970, 00:00:00 GMT.
As a consequence a new Date(0) will represent the date above, which is equivalent to January 1, 1970, 01:00:00 CET.
You might use a DateFormat and specify the TimeZone.
Example:        Time time = new Time(21160);
        DateFormat format = DateFormat.getTimeInstance();
        format.setTimeZone(TimeZone.getTimeZone("CET"));
        System.out.println(format.format(time));
        format.setTimeZone(TimeZone.getTimeZone("GMT"));
        System.out.println(format.format(time));Will output:
01:00:21
00:00:21

Similar Messages

  • Java programs do not work correctly in my computer.

    This is very simple. Every java program I have, such as the Java Control Panel or the LimeWire (downloads program) can't work correctly, meaning the program's window appears but not its content; showing a blank window instead of showing me the program. I have reinstalled the complete java software several times but nothing changes.
    I will appreciate a quick answer, and sorry for my bad english, thanks...
    Tomas. Buenos Aires, Argentina.

    OHHHHH!!! HOW STUBBORN I AM!!!. You were right, the problem started after my video card was reinstalled!. Thanks for the link, in fact, the porblem is perfectly registred by Java:
    www.java.com/en/download/help/5000041100.xml
    Thanks, this forum is the bbbest one ever!.
    Tomas, Buenos Aires, Argentina.

  • DB adaptor polling, edited sql does not work correctly

    Please considet the following table
    BPELProcess State
    BPEL1 0
    BPEL2 0
    My DB adaptor is polling on this table to check for the state 0.after reading it changes it to 1. and invokes the bpel process 1 .Bpel1 invokes another process which changes the state back to 0 .
    DBAdaptor polling freq is 2 min
    DB adaptor SQL is
    SELECT BPELPROCESS, STATE FROM INVOKEDMADMPKG WHERE (((BPELPROCESS = BPEL1) AND (STATE = 0)) AND (ROWNUM <= 1)) ORDER BY BPELPROCESS ASC FOR UPDATE NOWAIT
    but i used to see 2 instances every 2 minutes,i should see 1.
    when i deleted the 2nd row from the database table then it started working fine FOR SOME TIME and thenm the issue returned.
    I see twp bpel instances every 2 min
    Why cannot i pol on condition where BPEL PRocess =BPEL1 and State =0
    Is there a way to accomplish this
    Edited by: 850101 on Nov 14, 2012 2:10 PM

    850101 wrote:
    DB adaptor ... check for the state 0 ... changes it to 1 ... changes the state back to 0 ...BPEL will allways work in a transaction... So the change to 1 in the middle of the transaction doesn't make much sense, it will never be visible by other threads...
    I'm not sure what you're trying to achieve with that construction but I would say DbAdapter/Bpel wasn't designed to work like that... The results will be unpredictable, as you noticed yourself on your tests...
    If you need a BPEL to be invoked every two minutes you may have a look at using a scheduler...
    http://www.oracle.com/technetwork/middleware/soasuite/learnmore/soascheduler-186798.pdf
    Cheers,
    Vlad

  • SQL NLS_UPPER not working correctly for French?

    Hi,
    I have a database containing text in a large number of languages, and am trying to convert characters to uppercase based on their language, but am hitting a particular problem with French.
    In French, accented characters lose their accents in uppercase (é becomes E, à becomes A), whereas in other languages the accented character is retained.
    However, the SQL NLS_UPPER function is not following this language rule.
    Example:
    select 'é', upper('é'), nls_upper('é','nls_sort = french'), nls_upper('é','nls_sort = spanish') from dual;
    gives: é É É É
    it should give: é É E É (the 3rd column is different)
    My database characterset is AL32UTF8 - but this shouldn't matter as I am specifying the nls_sort.
    Has anyone encountered and solved this problem before?
    All the best.
    Niall.

    niallmcp wrote:
    In French, accented characters lose their accents in uppercase (é becomes E, à becomes A)This is not true.
    Where did you get this rule?
    In France, l' Académie Française recommends that all capital letters retain their accents.
    Texts that doesn't follow this recommendation are often seen as poorly written ones or at least of a lesser quality.
    NLS_UPPER works as expected.

  • Some time tech pad not working correctly

    I am buy a HP Pavilion laptop from awok.com. Some time mouse teach pad not working correctly some time open windows 8.1 time bar and some time i am using mouse teach pad then automaticly come right click popup menu coming some time i am try to scrol the page using mouse pad then automaticly Select all from the page so please help me

    Hello @BABUMON ,
    Thank you for visiting the HP Support Forums and Welcome. I have read about your HP Notebook and mouse freezing. Here is a document on how to troubleshoot the mouse and Touchpad sensitivities.
    If you will go to the section on Adjusting TouchPad or ClickPad pointing sensitivities it should help resolve the issue.
    I would be happy to assist if needed as there are many models of HP Notebooks, I would need the model number.
    How Do I Find My Model Number or Product Number?
    Please respond with which Operating System you are running:
    Which Windows Operating System am I running?
    Please let me know.
    Thanks.
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the bottom to say “Thanks” for helping!

  • I am using a Application in c dll calling from jni jar by java applet in firefox version 19.0 , the problem is click event message box will not working correct

    I am using a Application in c dll calling from jni jar by java applet in firefox version 19.0 , the problem is button click event message box or popup window will not working correctly. Please any one suggest me the steps to overcome this not responding or slowness in the responding problem of Button click event.

    Hello,
    In Firefox 23, as part of an effort to simplify the Firefox options set and protect users from unintentially damaging their Firefox, the option to disable JavaScript was removed from the Firefox Options window.
    However, the option to disable JavaScript was not removed from Firefox entirely. You can still access it from about:config or by installing an add-on.
    '''about:config'''
    # In the address bar, type "about:config" (with no quotes), and press Enter.
    # Click "I'll be careful, I promise"
    # In the search bar, search for "javascript.enabled" (with no quotes).
    # Right click the result named "javascript.enabled" and click "Toggle". JavaScript is now disabled.
    To Re-enable JavaScript, repeat these steps.
    '''Add-ons'''
    You can alternatively install an add-on that lets you disable JavaScript, such as
    *[https://addons.mozilla.org/firefox/addon/noscript/ No-Script] (to disable JavaScript on a per page basis, as required)
    *[https://addons.mozilla.org/firefox/addon/quickjava/ QuickJava] (to easily disable and enable JavaScript, automatic loading of images, and other content)
    Thank you and I hope this helps!

  • HT1338 Hi, as I shall correct Java for a new mountain ...? Java is currently not working at all Jarda

    Hi, as I shall correct Java for a new mountain ...?
    Java is currently not working at all
    Jarda

    Your question doesn't make much sense, so this is a WAG. Launch the Java Preferences.app in /Utilities, install the Java Runtime Environment when prompted, and, when that's finished, enable Java and Web Start apps.

  • Focus under Win2k does not work correctly

    Hi,
    we've found out that the focus does not work correctly under Windows 2000 in
    Seamless Mode (App is a Windows Application running on Windows Terminal Server
    2003), the same application has no problems under Windows XP, Apple Macintosh
    and Linux.
    Example: The application has a button which pop's up a small calendar window
    giving that window focus. In Tarantella under Win2k however you just see the
    window popping up shortly and then going in the background. As the window is in
    the background and you can't get the window back and you also cannot work
    further in that application as the rest is inactive.
    Only way is to do a right-click on the application in the taskbar, which brings
    the window in the foreground again. What makes this problem even harder to
    analyze is, that it sometimes even works correctly (around 3 of 10 times).
    We've mostly recognized this with modal windows. The native client does not have
    this problem, however as far as I know it does not support seamless mode.
    2. The second problem we got is, that if you click with the mouse into the
    initializing Window while the application starts up after you have clicked on an
    application Link in SGD (I mean the Pre-Login window of Windows which shortly
    shows up just before the Login Process begins),
    the application is not started seamlessly but is started within that window and
    you have no chance but closing an restarting the application to get it in
    seamless mode. This is seen on all Client Operating Systems by us and not only
    Windows 2000.
    The Client runs:
    Windows 2000 SP4 all updates installed
    Java: 1.5.0-5
    Browser: IE6.0 and Firefox 1.0.7
    Server: Windows 2003 Terminal Server (all updates installed)
    Tarantella: 4.20.909
    I hope that someone has at least a workaround.
    Regards
    Carsten

    I have organized some testcases attached are 3 Test Programs which work
    nice natively but got these problems under Tarantella under every Windows
    Operating System (the error is not Windows 2000 as I previously mentioned but
    also occurs on Windows XP).
    The interesting thing is that the Test Program made with .NET does not show this
    problem.
    Could someone please test these and tell if this error is reproducible on your
    systems as well ?
    Run these Testprograms natively, they show no misbehavior.
    Execute this from a SGD Webtop Session in Seamless Mode, see that
    the Modal window is not modal but shifts into the background on every 2 -3 click.
    Regards
    Carsten
    [ModalTestPrgs.zip]

  • Get the difference between two java.sql.Time values

    Hi, I'm developping a web application in which I need to to subtract one java.sql,Time value from another. The two values are stored in a database field of type DateTime. I used following code
    java.sql.Time start_time=resultset.getTime("startTime");
    java.sql.Time end_time=resultset.getTime("startTime");
    java.sql.Time diff=start_time-end_time;
    can u give me any comment on this code

    Remember what the Date/Time object in Java represents - a single point in time.
    Subtracting one from another gives you an amount of time elapsed between the two dates. Fine.
    Making a new Date out of that number is incorrect. The number no longer represents a point in time, but rather a duration.
    Its like saying "There is 10 seconds difference between the two times, so the time is now 1 Jan 1970, 00:00:10 GMT".
    The simple and stupid calculation is to take the milliseconds difference, and divide it to get to a more humanly readable value.
    // duration in milliseconds
    long duration = ?????
    long durationInSeconds = duration / 1000;
    long durationInMinutes = duration / (60 * 1000);
    long durationInHours = duration / (60 * 60 * 1000);
    // careful - not always true!
    long durationInDays = duration / (24 * 60 * 60 * 1000);
    NOTE: The "daysBetween" calculation is potentially complicated by Daylight Time adjustments. The simple approach does not necessarily work exactly.
    Cheers,
    evnafets

  • Email pushing not working correctly for office email - 3 seperate devices/carriers

    We switched email hosts several months ago and since our email pushing has not worked correctly. Our host/IT guy has been very unwilling to help me through this (I get the pleasure of being the in-house IT source)
    I personally am on AT&T have no problems with the other 3 emails I have set up on my blackberry. However I receive my work account one time a day at roughly 6:15. Another user is on Alltel and he receives spotty emails throughout the day, but his gmail account comes through instantly. The third user is on nextel and he receives his 2-3 times per day.
    I began to think this was an email host issue since the three of us are all on different carriers, until I found out a fourth user, also on nextel, receives his emails fine.
    Users 1-3 are on Outlook 07 on various versions of the Curve. We have all our messages to stay on the server.
    User 4 is on the older nextel blackberry push to talk, and is not on outlook. 
    We do not have an exchange server. Our emails were all set up through our devices.
    Any suggestions? The answers I have received through our carriers is to make sure that our messages are set to be left on the server. Everyone else at the office has given up - but for me this is the quest for the Holy Grail.......I'm determined find the answer!
    Thank you in advance for any suggestions.
    Caitlin Talbot 

    Potential solution for windows for a side-by-side install. This works for me.
    To setup a firefox install side by side so that links from external programs (like email) can open (so you don't get a "Firefox is already running but is not responding" message) do the following.
    The solution entails the use of the -no-remote switch. Don't use it for the default browser. Use it for the non default browser.
    I'll use firefox 3.6 and firefox 4.0 as examples but this should work for future versions.
    + Install firefox 3.6 and Firefox 4.0 in different directories. Eg.
    C:\Program Files\Mozilla Firefox\firefox.exe
    C:\Program Files\Mozilla Firefox 4\firefox.exe
    + Open profile manager. Start > Run : firefox.exe -ProfileManager
    + In profile manager create Two Profiles.
    firefox3.6
    firefox4
    + In profile manager select firefox 4 as your default (assuming you want to default to the latest) and tick "Don't ask at startup"
    + Create two windows shortcuts.
    * General: Mozilla Firefox 4 (default). Shortcut > Target: "C:\Program Files\Mozilla Firefox 4\firefox.exe". Shortcut > Start In: "C:\Program Files\Mozilla Firefox 4"
    * General: Mozilla Firefox 3.6. Shortcut > Target: "C:\Program Files\Mozilla Firefox\firefox.exe" -p firefox3.6 -no-remote. Shortcut > Start In: "C:\Program Files\Mozilla Firefox"
    That's it. Links from external programs should now open in your default browser.
    Further details see. [http://kb.mozillazine.org/Opening_a_new_instance_of_your_Mozilla_application_with_another_profile Opening a new instance of your Mozilla application with another profile]

  • Using java.sql.Time: Offset by 1 hour?

    I have a problem understanding the behaviour of the java.sql.Time class. As the following example shows.
    61952000 ms is the Time 17:12:32. If i feed a Time-Object with it and print the time or date I'll get "18:12:32",
    an offset of 1h. But if I use time.getTime(), I get my ms value which equals 17:12:32.
    As my timezone shows, I have a GMT offset of one hour. But why does the getTime() method not calculate
    the timezone offset to the ms?
    Time time = new Time(61952000);
            System.out.println(time.getTime() / 3600 / 1000); // 17 hours
            System.out.println( new Date(time.getTime()) ); // Thu Jan 01 18:12:32 CET 1970
            System.out.println(time.getTime()); // 61952000
            System.out.println(time); // 18:12:32
            System.out.println(Calendar.getInstance().getTimeZone());
             *  sun.util.calendar.ZoneInfo[id="Europe/Berlin",offset=3600000,dstSavings=3600000,
             *  useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[id=Europe/Berlin,
             *  offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,
             *  startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,
             *  endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]]
             */

    Thanks for your reply. But please take a look at the following code snippet. It intends to add a Timestamp representing the
    start of a day (time component 00:00:00) to a time component (having Date to 01-01-1970):
            Time time = new Time(61952000);
            Calendar c = Calendar.getInstance();
            System.out.println("time: " + time); // 18:12:32
            c.set(Calendar.HOUR_OF_DAY, 0);
            c.set(Calendar.SECOND, 0);
            c.set(Calendar.MINUTE, 0);
            c.set(Calendar.MILLISECOND, 0);
            System.out.println("date: " + c.getTime()); // Fri Apr 03 00:00:00 CEST 2009
            Timestamp timestamp = new Timestamp( c.getTimeInMillis() + time.getTime() );
            Date d = new Date(timestamp.getTime() );
            System.out.println("\nresult: " + d); // result: Fri Apr 03 17:12:32 CEST 2009If I assume that getting and setting the milis always deals with timezone independent values, but operating methods
    like toString(), getHour() etc use the timezone, then I can not explain the result (last line): 17:12:32 is the timezone
    independend value. Should'nt d.toString() show the timezone dependend value of 18:12:32?

  • LaserJet Pr0 200 color MFP M276nw Touch Screen not Working correctly

    Hello, I'm having an issue with a LaserJet Pr0 200 color MFP M276nw Touch Screen not Working correctly. I have followed the instructions to reset the printer, but now am unable to select 'English' as my language because every time I select the 'English' option 'Spanish' is selected. I am then given two options to select 'Si' or 'No' both of which can not be selected on the touch screen?
    Anybody know of a way round this?

    Hi @dnhowes ,
    I see that you are having issues with the touch screen not working correctly. I will do my best to help you.
    Make sure the printer is connected directly to a wall outlet. (don't use a power hub or a surge protector) This ensures the printer is receiving full power and may help this situation.
    Was it the Nvram reset back to factory settings that you tried or a hard reset?
    Try selecting the option on the display a little higher above the icon to see if that helps. Some touch screens are finicky.
    I find that on the Lab printers when I am selecting different menus.
    If the issue continues, please call our technical support at 800-474-6836 for further assistance. If you live outside the US/Canada Region, please click the link below to get the support number for your region.
    http://www8.hp.com/us/en/contact-hp/ww-phone-assist.html
    Have a nice day!
    Thank You.
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!
    Gemini02
    I work on behalf of HP

  • What will you do if any SQL is not working.in oracle 10g...apps 11.5.10.2

    What will you do if any SQL is not working. in oracle 10g....apps 11.5.10.2

    928714 wrote:
    yes sir.If you help me in answering my questions i wll be very thankful to you sir.
    tnx,I haven't a clue.
    As you have been advised in many of your posts, go study the documentation for whichever specific topic you are interested in.
    For me to answer your questions, I would need to go get that documentation.
    Then I would need to read that documentation.
    Then I would need to write a forum post that interprets what I think I learned from that documentation.
    It is so very much faster if YOU go do that instead of posting to a forum and expecting others to do it. You will remember what you study for a lot longer time if you teach yourself.

  • Forecast splitting not working correctly

    Hello
    I have a problem with the forecast splitting not working correctly.  We are using 2M->W     2 MONTH IN WEEKS     0  GLEI and most of the time this appears to work fine but there are occasions where the forecast is split for May, did not split Jun but split July.
    E.g. 
    06.05.2008     IndReq     VSF               9,424-
    12.05.2008     IndReq     VSF               20,845-
    19.05.2008     IndReq     VSF               30,925-
    27.05.2008     IndReq     VSF               24,740-
    02.06.2008     IndReq     VSF               134,257-
    01.07.2008     IndReq     VSF               25,771-
    07.07.2008     IndReq     VSF               32,213-
    14.07.2008     IndReq     VSF               32,214-
    21.07.2008     IndReq     VSF               32,213-
    28.07.2008     IndReq     VSF               25,770-     
    Do any of you Guru's have any idea why this would happen?
    Many thanks
    Sue

    I checked it in MD67
    it is working fine.
    In MD61 - my demand is 800 each for June and July. it hjas splited as below
    system is dividing the total qty on daily basis and then multiplying by no days in that week covered by requirement
    W 22.2008             26.667
    W 23.2008            186.667
    W 24.2008            186.666
    W 25.2008            186.667
    W 26.2008            186.667
    W 27.2008             26.666
    W 27.2008            154.839
    W 28.2008            180.645
    W 29.2008            180.646
    W 30.2008            180.645
    W 31.2008            103.225

  • System Update not working correctly

    Hi forum,
    System Update (Version 4.00.0024) is not working correctly on my T500 with Windows 7.
    1: Not detecting old versions
    SU is not detecting, that there is an old version of Access Connection (5.42) installed although there is a new version 5.50 avaliable. I had to do a manual update.
    2: Not installing a suggested update
    Each time I run SU, I get a suggested update for "Fix for Issue of HDD with HDP Detection for Windows Vista/7". After downloading there comes a meaningless message "package was not installed" (Paket wurde nicht installiert). No hint for any error.
    3: Some drivers (e.g. for the ultranav) have not been downloaded at all - I had to test the functions of some hardware components and download the appropriate drivers manually in case of malfuncion.
    Probably there is a solution known within the forum community, at least this should be a message to lenovo (I received no response from the help desk when reporting this finding).
    Regards
    AH_DE

    Dear Herik,
    thanks for your answer.
    I checked the log  file and found thousands of entries. Here are the lines related to "Fix for ...".
    Info    2010-02-03 , 08:40:37
              bei Tvsu.Gui.CustomComponents.UpdatePanel.SynchronizeBoxPackage(Object sender, EventArgs args)
              Message: Selected to install: Fix for Issue of HDD with HDP Detection for Windows Vista/7, with
    Info    2010-02-03 , 08:40:43
              bei Tvsu.Coreq.LoadCoreqsProcessor.ProcessUpdatesImplementation(Update[] ups)
              Message: Candidate list:
    Fix for Issue of HDD with HDP Detection for Windows Vista/7[reboot type 3]
    Info    2010-02-03 , 08:40:57
              bei Tvsu.GenericPackageInstaller.GenericPackageInstaller.ExtractFiles(String extractCommand)
              Message: osfq03ww.exe -s -ex -fC:\SWTOOLS\OSFIXES Extract command was executed sucessfully in Fix for Issue of HDD with HDP Detection for Windows Vista/7 update
    Info    2010-02-03 , 08:40:57
              bei Tvsu.GenericPackageInstaller.CmdInstaller.InstallUpdate()
              Message: Update Fix for Issue of HDD with HDP Detection for Windows Vista/7 is being install using Windows Service
    Info    2010-02-03 , 08:40:57
              bei Tvsu.Engine.Process.PackageInstallerProcess.InstallNewUpdates()
              Message: Update Fix for Issue of HDD with HDP Detection for Windows Vista/7 installation failed
    ADDITIONAL ENTRIES 
    Info    2010-02-03 , 08:40:57
              bei Tvsu.Gui.FlowScreens.Results.AdjustComponent()
              Message: System updated:
              Installed=0
              Not Installed=Tvsu.Beans.Update[]
              Deferred=0
              Download Failed=0
              Hidden=0
    Severe          2010-02-03 , 08:41:17
              bei Tvsu.Sdk.SuSdk.ShutDownApplication()
              Message: Has happened an exception while the UNCAuthenticator.Shutdown() was executedShare name can not be null or empty
    Since I'm a normal user only, I can't interprete this information. Do you know what to do?
    Kind Regards
    AH_DE

Maybe you are looking for