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

  • Home
  • SEARCH
  • 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 8028409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:07:49+00:00 2026-06-05T00:07:49+00:00

I have a table which stores both unix time and the equivalent time stamp.

  • 0

I have a table which stores both unix time and the equivalent time stamp.

CREATE TABLE tbl_time
(
    time_unix BIGINT,
    time_timestamp TIMESTAMP WITHOUT TIME ZONE
);

The database is in PostgreSQL. database has been configured with Asia/Tehran time zone.
for example:

1333436817, 2012-04-03 11:36:57

When I convert the unix time into string format in python with:

datetime.datetime.fromtimestamp(1333436817)

it gives me: datetime.datetime(2012, 4, 3, 11, 36, 57) which is correct and equal to database. But when I do this conversion with java using:

Calendar c = Calendar.getInstance(TimeZone.getTimeZone("Asia/Tehran"));
c.setTimeInMillis(1333436817 * 1000);
System.out.println(c.getTime());

It gives: Sat Jan 24 06:12:35 IRST 1970. The system itself is running under Asia/Tehran time zone. I’m using PostgreSQL 8.4.11 on Debian 6.0.5 with python 3.1 and openjdk 6. Can anyone help?

  • 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-05T00:07:50+00:00Added an answer on June 5, 2026 at 12:07 am

    The result of 1333436817 * 1000 is too big for an integer so it overflows. Java will not promote the type for you automatically in this case.

    Try that:

        c.setTimeInMillis(1333436817 * 1000L);
    

    Notice the L that force your calculation to use long integer.

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

Sidebar

Related Questions

I have a MYSQL-Table which stores scores. Every time a user improves a new
I have a mysql table field set as time type which stores data in
I have a table which stores test results like this: user | score |
Imagine I have a table which stores a series of sparse vectors. A sparse
While working with ActiveRecord I have a table which stores a serialized array of
I have a database table A which stores records, A has a primary key
I have a MySql table called reviews which stores a lot of product reviews,
I have a table, Messages, which is set out as follows: This table stores
I have a table which stores comments, the comment can either come from another
I have a table in mysql which stores (among other columns) a bitmask as

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.