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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:02:49+00:00 2026-05-24T19:02:49+00:00

Second EDIT: Looks like my issue might be where the date is set from

  • 0

Second EDIT:

Looks like my issue might be where the date is set from the date picker dialog:

// the callback received when the user "sets" the date in the dialog
private DatePickerDialog.OnDateSetListener mDateSetListener =
  new DatePickerDialog.OnDateSetListener() {

    public void onDateSet(DatePicker view, int year, int monthOfYear,
      int dayOfMonth) {
        mYear = year;
        mMonth = monthOfYear + 1;
        mDay = dayOfMonth;
        updateDisplay();    
    }
}

I am +1 to the month, but never taking that off again when i compare for the database…

EDIT:
Okay I did double checked this (finally got to it). Sure enough the

Date test1 = new Date(cobj.getTime().getTime()); //from the Calendar passed in

So the date retrieved from the database is the right date. The one that comes back from my dialog even though it displays correctly using:

    String val = cobjstrong text.get(Calendar.MONTH) + "/" +
      cobj.get(Calendar.DAY_OF_MONTH) + "/"+ cobj.get(Calendar.YEAR);   

…is actually a month ahead when I look at the object as cobj.getTime().getTime(); (a long for the dates I use). Is there some other method or conversion I am missing?

Should I not be using the .getTime on the Calendar Object just to get a long from that (with a call to getTime again on the Date object?). Sometimes it seems to me that my best bet is to store longs in milliseconds to the database and then just retrieve them and do the Date conversions there?

PRE-EDIT question:

SO I have this Date field in a database, that I can store a date to and read a date from, when I read em… I have to add a +1 to the .getMonth() because date returns that as a number 0-11, instead of 1-12. After dealing with this issue and a few others (like .getMinutes returning an int, so if the time is 5:00 only 5:0 is displayed?)but I finally got the date displaying just great, but I found out when I try to query the database on a date things are off I am guessing by one month. So that means a month of

9/8/2011

(dd/mm/YYYY) format, will not query right when using the following ORMLite query:(Notice the .qe, GreaterThanEqual in ormlite).

public void updateDatePickerButtonUI(Calendar cobj, int widget) {
    String val = cobj.get(Calendar.MONTH) + "/"+ cobj.get(Calendar.DAY_OF_MONTH)
        + "/"+ cobj.get(Calendar.YEAR);
    btnChooseDateReview.setText(val);
    //the following just won't query correctly, its a month off
    try {
        //sessionDate
        QueryBuilder<SessionsData, Integer> sb =
            mDB.getSessionsDao().queryBuilder();
        sb.where().ge(SessionsData.SESSIONSDATE_ID_NAME, cobj.getTime());
        List<SessionsData> sessions = mDB.getSessionsDao().query(sb.prepare());
        for (int i = 0; i < sessions.size(); i++) {
            try {
                mDB.getClientsDao().refresh(sessions.get(i).getClient());
                mDB.getPackagesDao().refresh(sessions.get(i).getPackage());
            } catch (SQLException e) {
                ...
            }
        }
        theSessions = new CustomSessionReviewAdapter(mContext, 
            R.layout.session_review_row,  sessions);
        theSessions.notifyDataSetChanged();
        theList.setAdapter(theSessions);
    } catch (SQLException e) {
        ...
    }
}

So I must be handling dates wrong, maybe adding to the month for display purposes is not right? or something… maybe in my query with the Calendar object, I can make that month part 0-11 or something…not sure what avenue to take here.

  • 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-24T19:02:51+00:00Added an answer on May 24, 2026 at 7:02 pm

    I’m a little confused @CodeJoy. I don’t see any references to +1 in your code. I assume that you are doing a +1 while you are building the val for your button text?

    ORMLite stores the Date field as a string via the Sqlite driver (i.e. something like 2011-08-10 18:33:30.316) and I am wondering if the conversion to/from a Calendar object generates a Date that does not match the database exactly. Maybe the milliseconds have been truncated? Are you creating a Calendar from the button date string?

    Most likely your problem has nothing to do with the +/- 1 issue around the month. The getTime() method should do that conversion appropriately.

    I would debug your app and see what the cobj.getTime() returns for a date and then do a mDB.getSessionsDao().queryForAll() and take a look at how the Date is being returned from the database driver.

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

Sidebar

Related Questions

EDIT I solved the issue by forking the process instead of using threads. From
I have a query that looks like the following: SELECT * FROM table WHERE
Seems like everyone have issue accessing local machine or internet etc from emulator. All
I'm working on a graphical application which looks something like this: while (Simulator.simulating) {
my CSV content looks like this 1234,123;123;123 5675,123;567;234;565 No Space is provided at the
I have two repeaters that looks like this : Arrange By: Name | Age
I would like to build a navigation which works and looks like on the
(Sorry if it's a trivial question.) I have documents that looks like this (Python
I'm trying to set up an issue tracker on my server, running apache2. However,
SELECT count(*) c FROM full_view WHERE verified > ( DATE (NOW()) - INTERVAL 30

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.