Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8018589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:09:43+00:00 2026-06-04T21:09:43+00:00

I have MonetDB database with table containing user table: CREATE TABLE user ( birth_date

  • 0

I have MonetDB database with table containing user table:

CREATE TABLE user
(
    birth_date TIMESTAMP NOT NULL
);

birth_date is saved in GMT without DST. (This is the default behavior of MonetDB). So I should change the TimeZone in my application. Here is my code:

Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
Connection con = DriverManager.getConnection("jdbc:monetdb://localhost/online", "monetdb", "monetdb");      
Statement st = con.createStatement();
ResultSet rs;

rs = st.executeQuery("SELECT * FROM user");
while (rs.next()) {
    Calendar c = Calendar.getInstance(TimeZone.getTimeZone("Asia/Tehran"));
    c.setTime(rs.getTimestamp("birth_date"));
    System.out.println(c.get(Calendar.YEAR) + "-" + c.get(Calendar.MONTH) + "-" + c.get(Calendar.DAY_OF_MONTH) + " " + c.get(Calendar.HOUR_OF_DAY) + ":" + c.get(Calendar.MINUTE) + ":" + c.get(Calendar.SECOND));
}

But this code print the same TIMESTAMP in the database. Is this the wrong way to convert TimeZone? I’m using MonetDB version 11.9.5-20120516 on Debian 6 with openjdk 6. Here is the monetdbd getall /home/dbfarm:

dbfarm           /home/dbfarm/
status           monetdbd[4187] 1.6 (Apr2012-SP1) is serving this dbfarm
mserver          /usr/bin/mserver5
logfile          /home/dbfarm//merovingian.log
pidfile          /home/dbfarm//merovingian.pid
sockdir          /tmp
port             50000
exittimeout      60
forward          proxy
discovery        yes
discoveryttl     600
control          yes
passphrase       {SHA512}ba3253876aed6bc22d4a6ff53d8406c6ad864195ed144ab5c87621b6c233b548baeae6956df346ec8c17f5ea10f35ee3cbc514797ed7ddd3145464e2a0bab413
mapisock         /tmp/.s.monetdb.50000
controlsock      /tmp/.s.merovingian.50000
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:09:43+00:00Added an answer on June 4, 2026 at 9:09 pm

    Finally I got the answer.

    MonetDB runs in GMT by default and because Asia/Tehran was not available in database configuration so I need to convert time to Asia/Tehran time zone in my application. JVM takes its default TimeZone from OS and my OS was set to Asia/Tehran. So the program runs in Asia/Tehran by default and changing it to ‘Asia/Tehran` again in code doesn’t make any benefit. what I did was this:

    1. change the default TimeZone of JVM to UTC when application starts.
    2. retrieve record from database
    3. change TimeZone to Asia/Tehran

    Here is code:

    /* Change the default TimeZone of JVM */
    TimeZone.setDefault(TimeZone.getTimeZone("UTC")); 
    Calendar c = Calendar.getInstance();
    Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
    Connection con = DriverManager.getConnection("jdbc:monetdb://localhost/online", "monetdb", "monetdb");
    Statement st = con.createStatement();
    ResultSet rs;
    rs = st.executeQuery("SELECT * FROM user");
    /* In each iteration:
     * 1. set TimeZone to UTC
     * 2. fetch record
     * 3. convert to Asia/Tehran and so on ... */
    while (rs.next()) {
        c.setTimeZone(TimeZone.getTimeZone("UTC"));
        c.setTime(rs.getTimestamp("birth_date"));
        System.out.println(c); /* This is original values in the database */
        c.setTimeZone(TimeZone.getTimeZone("Asia/Tehran"));
        System.out.println(c); /* This is the values I'm looking for */
    }
    

    Note that without TimeZone.setDefault(TimeZone.getTimeZone("UTC")); this won’t work. becuase JDBC has connected to database and converted the time to the default TimeZone of the JVM (which is Asia/Tehran in this case) before you can do any conversion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have 2 questions : A computer with 32-bit address uses 2-level page table (9
have a nice day. I got problem when trying to create an image from
Have searched the database but need to specifically sum(of hours flown or days off)in
Have some dates in my local Oracle 11g database that are in this format:
Have a table with 3 million rows and would like to partition it. There
have written this little class, which generates a UUID every time an object of
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
Have done quite a bit of searching for a guide (of any substance) for
Have deployed numerous report parts which reference the same view however one of them
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.