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 7029241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:30:46+00:00 2026-05-28T00:30:46+00:00

The dates in my sqlite in android is saving 12/31/69 instead of the actual

  • 0

The dates in my sqlite in android is saving 12/31/69 instead of the actual date. I have this in my db adapter:

    + KEY_DATE + " DATETIME DEFAULT CURRENT_TIMESTAMP

In my activity i have

        Date date = new Date(cursor.getLong(cursor.getColumnIndex(mDbHelper.KEY_DATE)));
        mDateFormat = DateFormat.getDateInstance(DateFormat.SHORT);

When I do a Log.d(“Debug”, mDateFormat.format(date)) it outputs 12/31/69 what am I doing wrong?

  • 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-05-28T00:30:47+00:00Added an answer on May 28, 2026 at 12:30 am

    mDateFormat is just a date format – you haven’t used the value of date from the previous line anywhere. You want something like:

    Log.d("Debug", mDateFormat.format(date));
    

    Now that may still give the wrong value – but we can move on to that. It would really help if you’d show more of what’s in your adapter than the partial statement you’ve got there. We haven’t got nearly enough context.

    EDIT: You’re calling getLong, but you’ve got a default value of CURRENT_TIMESTAMP, which looks like it’ll come out as text:

    If the default value of a column is CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP, then the value used in the new row is a text representation of the current UTC date and/or time. For CURRENT_TIME, the format of the value is “HH:MM:SS”. For CURRENT_DATE, “YYYY-MM-DD”. The format for CURRENT_TIMESTAMP is “YYYY-MM-DD HH:MM:SS”.

    It’s unclear to me what you’d expect to happen when you fetch that value as a long… according to the documentation, the result is implementation-specific – I suspect it’s returning 0, giving you a date of the Unix epoch, which would make sense with your output if you’re in a time zone west of Greenwich.

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

Sidebar

Related Questions

I have an SQLite database within my Android application, which stores dates as integers.
I have two dates: how do I compare which one is greater date in
I am trying to update a datetime column in an android sqlite db to
I'm using SQLite in an Android application. In all of my tables I have
I am storing the dates in a SQLite database in this format: d-MMM-yyyy,HH:mm:ss aaa
I have created tables in android sqlite using create statement and also inserted values
This is about Android and SQLite database. Simply, I want to know, how can
I have difficulties comparing the date from my android os to a date stored
I'm creating a new SQLite database in Android via this method: public void onCreate(SQLiteDatabase
I have basically finished developing an android app that makes use of SQLite databases

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.