How do I change TimeStamp from US server to UK time

Hello,
I am based in the UK. My hosting company is based in the US. I am using a MySql database. All the database tables have timestamps that are set to the local machine time.
I would like to change the timestamp so that it is GMT.
Can you please tell me how I would go about doing this?
Is their any code available to enable me to insert the timestamp as a GMT date or do I set the value from the mysql database end.
Thanks
Andrew

Timestamp values in Java (java.sql.Timestamp) are GMT internally (actually, they're implemented as a long giving the number of milliseconds since 1. january, 1970).
Date values in SQL, on the other hand, are normally stored in the local time zone.
What you need to do, is tell JDBC what time zone you want the stored values to be in, like this:
When inserting (using a PreparedStatement):
  stmt.setTimestamp(column, myTimestamp, Calendar.getInstance(TimeZone.getTimeZone("GMT")));When reading back from a ResultSet:
  Timestamp ts = rs.getTimestamp(column, Calendar.getInstance(TimeZone.getTimeZone("GMT")));Now, you know that the timestamp value you've read back from the database does not have any bias to it introduced by the local timezone of the database server. The next step is to represent the Java Timestamp value to the user, and at this stage you may want to specify which time zone you want for the rendered timestamp, like this:
  import java.text.DateFormat;
  import java.text.SimpleDateFormat;
  // convert the Timestamp to a String in a controlled manner
  // see the documentation for SimpleDateFormat for how you specify the format string
  DateFormat df = new SimpleDateFormat("yyyy.MM.dd HH.mm.ss");
  // need to set the time zone, or the server's time zone will be used
  // if you can somehow figure out the time zone where the user is
  // sitting, you may use that instead, to provide dates relative to
  // the user instead of the server
  df.setTimeZone(TimeZone.getTimeZone("GMT"));
  String outValue = df.format(myTimestamp);
  // output the converted value, maybe
  System.out.println(outValue);Similarly, you may use the parse() method of DateFormat to parse a String as a java.util.Date, which may then be converted into a Timestamp.
The general principles are as follows:
- internally, Java Timestamps, Dates etc. are stored relative to 1. january 1970, GMT
- when getting date values into or out of Java, time zones may have to be considered
- for converting to/from Strings (eg. for UI purposes), use the java.text.DateFormat class
- for communicationg with an SQL database via JDBC, use the set/get-Timestamp methods with the added Calendar argument
NB! Please be aware that I didn't actually try to compile this code, so bugs may be present.

Similar Messages

  • How do I change the incoming mail server settings in Mac Mail?

    I have a Mac 27" update to Yosemite 10.10.2. I have 25 GB free in storage. I have been having trouble with road runner email and found out today that they are changing their email settings. How do I change the incoming mail server settings in Mac Mail from pop-server.columbus.rr.com to mail.twc.com?

    Replying to yourself doesn't help:
    Reply to the proper person.

  • I don't know much about computers can anyone walk me through this ? How Do I Change The Software Update Server Address On A Client  ? what do I open and how do i put it in the right spot?

    I don't know much about computers can anyone walk me through this ? How Do I Change The Software Update Server Address On A Client  ? what do I open and how do i put it in the right spot?

    The simplest method is to run a defaults command on the client Macs (easily pushed via Apple Remote Desktop):
    defaults write com.apple.SoftwareUpdate CatalogURL 'HTTP_URL_FOR_CATALOG'
    for a user. If you run it via sudo it will set it for whenever you use softwareupdate as root.
    The HTTP_URL_FOR_CATALOG has been changed with Mac OS X 10.6.  If you use MCX it will automatically pick the new catalog – however if  doing it manually the following URLs need to be used for whichever  client version is in question:
    Mac OS X 10.4: http://mysus.example.com:8088/index.sucatalog
    Mac OS X 10.5: http://mysus.example.com:8088/index-leopard.merged-1.sucatalog.sucatalog
    Mac OS X 10.6: http://mysus.example.com:8088/index-leopard-snowleopard.merged-1.sucatalog
    Mac OS X 10.7: http://mysus.example.com:8088/index-lion-snowleopard-leopard.merged-1.sucatalog
    Mac OS X 10.8: index-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog
    To double check this applied you can run the following command:
    /usr/libexec/PlistBuddy -c Print /Library/Preferences/com.apple.SoftwareUpdate.plist
    and /usr/libexec/PlistBuddy -c Print ~/Library/Preferences/com.apple.SoftwareUpdate.plist
    to see what settings are for the computer and user appropriately.
    If  this is working correctly when running Software Update (GUI) you should  see the server address appear in parenthesis in the title of the  window.
    MCX
    Another alternative is to use Workgroup  Manager to manage the preferences via MCX from your server. This can be  done for users, or for computers if they are bound to your Open Directory.
    If you are using 10.5 Server or newer: you can simply use the Software Update section under Preferences.
    Manually:
    Choose the accounts, computers, or groups to have the preference applied to.
    Click on Preferences, and then the Details tab
    Press the Add… button and navigate to /Library/Preferences/com.apple.SoftwareUpdate.plist
    Press Edit…
    Under Often, add a New Key and enter the name CatalogURL
    Make sure the type is string and then enter your SUS URL (eg. http://mysus.example.com:8088/index.sucatalog or if using 10.6: http://mysus.examle.com:8088/ – see above from the defaults section)
    Press  Apply Now, then Done. Once users/computers have refreshed their MCX  settings (usually the next login or restart) the new settings will take  over.
    If this is working correctly when running Software  Update (GUI) you should see the server address appear in parenthesis in  the title of the window.
    In order to have a system-wide configuration one has to run the following:
    sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate CatalogURL "http://your.updates-server.lan:8088/index.sucatalog"
    In order to correctly work both on Leopard and Snow Leopard the right command to issue is:
    defaults write /Library/Preferences/com.apple.SoftwareUpdate CatalogURL "http://your.updates-server.lan:8088/index-leopard-snowleopard.merged-1.sucatalog"
    Happily used and tested on my network
    The DNS trick that Chealion points out is fantastic. I use it at our office, and every computer on our LAN  will automatically pull the updates from the local repository at high  speed without any configuration.
    Create the swscan.apple.com DNS zone on your internal DNS server, and have it resolve via an A record to your Mac
    Tags: automaticupdates mac clients macosx setting as default software update
    Category: Serverfault
    Share
    0
    0
    Google +
    0
    0
    0
    5
    You might also like:
    Can I Update My Jb 4s To 6.1.2 Without Restore? Tue. Jan 21st, 2014
    Iphone 4 Not Charging After Update To IOS6 
    IPad 2 Not Updating To IOS 5.1 
    How To Resolve The â€âunable To Install Update” Error For OTA IOS Updates? 
    What Is â€âSoftware Update” Doing When It Says â€âChecking For New Software”? 
    Advertisement
    Comment
    - See more at:  http://www.eonlinegratis.com/2013/how-do-i-change-the-software-update-server-add ress-on-a-client-mac-to-use-my-own-server/#sthash.YhHp5zWk.dpuf

  • Hi,how can i transport objects from one server to other like (Dev To Qty)

    Hi Sir/madam,
       Can u explain how can i transport objects from one server to other like (Development To Quality To Production).
    Regards,
    Vishali.

    Hi Vishali,
    Step 1: Collect all Transports(with Packages) in Transports Tab(RSA1)- CTO
    Step 2: Release the subrequests first and then the main request by pressing Truck button
    Step 3: STMS or Customized transactions
    Object Collection In Transports:
    The respective Transports should have the following objects:
    1. Base Objects -
    a. Info Area
    b. Info object catalogs
    c. Info Objects
    2. Info Providers u2013
    a. Info Cubes
    b. Multi Providers
    c. Info Sets
    d. Data Store Objects
    e. Info Cube Aggregates
    3. Transfer Rules u2013
    a. Application Components
    b. Communication Structure
    c. Data Source replica
    d. Info Packages
    e. Transfer Rules
    f. Transformations
    g. Info Source Transaction data
    h. Transfer Structure
    i. Data sources (Active version)
    j. Routines & BW Formulas used in the Transfer routines
    k. Extract Structures
    l. (Note) If the transfer structures and related objects are being transferred without preceding
    Base Objects transport (e.g. while fixing an error) it is safer to transport the related Info
    Objects as well.
    4. Update Rules u2013
    a. Update rules
    b. Routines and formulas used in Update rules
    c. DTPs
    5. Process Chains u2013
    a. Process Chains
    b. Process Chain Starter
    c. Process Variants
    d. Event u2013 Administration Chains
    6. Report Objects u2013
    a. Reports
    b. Report Objects
    c. Web Templates
    Regards,
    Suman

  • How do I change Itunes from one account to two in my home?

    how do I change Itunes from one account to two in my home?

    You don't.
    What are you trying to do?

  • I bought a new 5c and transferred from an old update from my iPhone 4.  The only issue I have is the name of my new phone.  How can I change it from Amyiphone4 to something else?

    I bought a new 5c and transferred from an old update from my iPhone 4.  The only issue I have is the name of my new phone.  How can I change it from Amyiphone4 to something else?

    settings - general - about - name - make the changes

  • How to upload XML file from Application server.

    Hi,
    How to upload XML file from Application server.Please tell me as early as possible.
    Regards,
    Sagar.

    Hi,
    parameters : p_file type ibipparms-path obligatory.
    ***DOWNLOAD---->SAP INTO EXCEL
    filename1 = p_file.
    call function 'GUI_DOWNLOAD'
      exporting
      BIN_FILESIZE                    =
        filename                        = filename1
        filetype                        = 'ASC'
      APPEND                          = ' '
      WRITE_FIELD_SEPARATOR           = 'X'
      HEADER                          = '00'
      TRUNC_TRAILING_BLANKS           = ' '
      WRITE_LF                        = 'X'
      COL_SELECT                      = ' '
      COL_SELECT_MASK                 = ' '
      DAT_MODE                        = ' '
      CONFIRM_OVERWRITE               = ' '
      NO_AUTH_CHECK                   = ' '
      CODEPAGE                        = ' '
      IGNORE_CERR                     = ABAP_TRUE
      REPLACEMENT                     = '#'
      WRITE_BOM                       = ' '
      TRUNC_TRAILING_BLANKS_EOL       = 'X'
      WK1_N_FORMAT                    = ' '
      WK1_N_SIZE                      = ' '
      WK1_T_FORMAT                    = ' '
      WK1_T_SIZE                      = ' '
    IMPORTING
      FILELENGTH                      =
      tables
        data_tab                        = it_stock
      FIELDNAMES                      =
    exceptions
       file_write_error                = 1
       no_batch                        = 2
       gui_refuse_filetransfer         = 3
       invalid_type                    = 4
       no_authority                    = 5
       unknown_error                   = 6
       header_not_allowed              = 7
       separator_not_allowed           = 8
       filesize_not_allowed            = 9
       header_too_long                 = 10
       dp_error_create                 = 11
       dp_error_send                   = 12
       dp_error_write                  = 13
       unknown_dp_error                = 14
       access_denied                   = 15
       dp_out_of_memory                = 16
       disk_full                       = 17
       dp_timeout                      = 18
       file_not_found                  = 19
       dataprovider_exception          = 20
       control_flush_error             = 21
       others                          = 22
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    Regards,
    Deepthi.

  • HT1491 how do i change over from the american itunes store to the Australian store?

    How do i change over from the american itunes store to the Australian store? I was switched over when I was looking for something that was not available in the Australian store and now I cant get back.

    I have the same problem, anyone got an answer?

  • How can i copy ztable from development server to ides server?

    how can i copy ztable from development server to ides server?

    Hello Suresh
    The simplest way is to use a transport request.
    Another possibility is to check for SAPLINK plugins which allow to download table definitions (including data elements and domains) into a flat file. Upload on IDES again via [SAPLINK|https://wiki.sdn.sap.com/wiki/display/ABAP/SAPlink].
    Regards
      Uwe

  • How can I change store from US store to Emirati store on my iphone?

    How can I change store from US store to Emirati store on my iphone?

    Settings > iTunes & App Stores > tap your Apple ID: > View Apple ID > Country/Region
    Regards.
    Forum Tip: Since you're new here, you've probably not discovered the Search feature available on every Communities page, but next time, it might save you time (and everyone else from having to answer the same question multiple times) if you search a couple of ways for a topic, both in the relevant forums and in the Apple Knowledge Base, before you post a question.

  • How do i change default from adobe to preview

    how do i change default from adobe to preview?

    Control mouse click a file type you want to open with Preview (or right mouse click if available) Open With -> Other...  Navigate to Preview and select Always Open With, before clicking open.

  • How do I changing the default WIKI Server name on OS x Lion Server?

    How do I changing the default WIKI Server name on OS x Lion Server? Enterprise solutions suggested I post this question here to get a direct answer. I have searched everywhere... This would be the META TAG On the top of browsers...

    I went looking for this answer, to no avail.
    Solution I used:
    step 1 - Navigate to the folder /usr/share/collabd/coreclient/locales/en.lproj/ and open the only file there called default.strings.
    step 2 - somewhere around lines 74 & 164 you will see the default title "OS X Lion Server". I'm sure only one of the is required to be changed to adjust the title on the window, but I changed both to my desired title. Save and close. If asked for authentication, enter you administrator details.
    step 3 - restart the server (or wiki service may work too)
    step 4 - done and your Wiki welcome page should show the new title
    Finally I have a bookmark that means something by default.
    Hope this helps

  • HT201304 How do I change back from UK iTunes to Australia on the iPad!!

    How do I change back from UK iTunes to Australia on the iPad!! I changed it by accident and can't find where to change it back on the iPad! Syncing to computer didn't help.

    Follow this link, which will walk you the steps:  http://support.apple.com/kb/ht1311

  • How to access Oracle 8g from SQL Server 2005 SP3 EE 64 Bits ?

    Dear All,
    How to access Oralce 8g from SQL Server 2005 SP3 EE 64 Bits (liked server).
    Best regards,
    Miguel Gavinhos

    Hi!
    For the Oracle version is 8.1.6. what should I install, to access Oracle trought a linked server.
    Best regards
    Miguel Gavinhos

  • How to download ALL MAIL from the server in a Mail app ?

    How to download ALL MAIL from the server in a Mail app ? I want all the mail messages, sent, received ON my computer... Thanks much !!!!!!!

    In Mail's Accounts/Mailbox Behavior preference pane make sure these 4 checkboxes are NOT checked:
    OT

Maybe you are looking for