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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:48:40+00:00 2026-06-03T02:48:40+00:00

I have a simple todo app that where each ‘todo’ has a title, description,

  • 0

I have a simple todo app that where each ‘todo’ has a title, description, done status, created date and modified date.

Todo.java

package com.anna.todos.models;

import java.util.Date;

public class Todo {
    private long id;
    private String title;
    private String text;
    private boolean done;
    private Date createdDate;
    private Date modifiedDate;

    public Todo() {
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public boolean isDone() {
        return done;
    }

    public void setDone(boolean done) {
        this.done = done;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public Date getModifiedDate() {
        return modifiedDate;
    }

    public void setModifiedDate(Date modifiedDate) {
        this.modifiedDate = modifiedDate;
    }
}

The created date and modified date are stored in the SQLite database as integers. When I get them from the database I want to be able to correctly convert them to Date objects and when I go to save a todo, I would like to be able to get the integer or long equivalents of those Date objects. (This was done as per the suggestions from another StackOverflow post).

The following is the code that I used to get the dates from the database:

    createdDate = new Date(cursor.getInt(4) * 1000);
    modifiedDate = new Date(cursor.getInt(5) * 1000);

And to save the dates….

    createdDate = Calendar.getInstance().getTime();
    values.put(DatabaseHelper.TODO_CREATED_DATE, createdDate.getTime() * 1000);

My problem now is that the created and modified dates are not being correctly converted. Below are the debugging statements for loading the dates from the database:

04-29 09:21:35.649: I/TodoEditActivity(3954): populateFields() => createdDate=01 Jan 1970 10:33:01
04-29 09:21:35.649: I/TodoEditActivity(3954): populateFields() => modifiedDate=01 Jan 1970 10:34:19

And the debugging statements for saving the dates:

04-29 09:22:00.653: I/TodoEditActivity(3954): saveTodo() => createdDate=01 Jan 1970 10:33:01
04-29 09:22:00.653: I/TodoEditActivity(3954): saveTodo() => modifiedDate=29 Apr 2012 09:22:00

Is there anything that I should do to fix this?

  • 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-03T02:48:41+00:00Added an answer on June 3, 2026 at 2:48 am

    I suspect the value for createdDate stored in the database is 0 (or a small value). Try setting a variable to cursor.getInt(4) and debug it so you can verify the value gives you a current date. You shouldn’t need to multiply by 1000 if you use Date.getTime() or Calendar.getTimeInMillis().

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

Sidebar

Related Questions

I have a simple android app that has quite a number of buttons, all
I have an app that has 2 tabs. Each tab loads an xml file
I have a fairly simple web app that uses cookies to store some information
I have a simple Smart TV app that shows a list of items in
I'm trying to write a simple app that has several internal pages. From #page2
I have a simple app that allows people to upload pictures to a server.
I have an activity that has two tabs and a list view in each.
I have a simple VB.NET 2008 app that helps users to edit fields in
I have an app that does a simple calculation from 2 text fields, the
I have a simple Android App using simple js, jquery mobile and phonegap that

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.