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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:52:49+00:00 2026-06-13T00:52:49+00:00

I have a database in my Android app that has dates formatted like this:

  • 0

I have a database in my Android app that has dates formatted like this: 201274 for July 4, 2012 and 20121016 for October 16, 2012. I display the date of the DB row using SimpleDateFormat so that for today, it grabs the date 20121016 and displays 2012-10-16. The code is like so:

    private void convertDBdate() {
    convertDateTextView.setText(gotDt);

    String dateStr = convertDateTextView.getText().toString();
    SimpleDateFormat inputFormatter = new SimpleDateFormat("yyyyMd");
    SimpleDateFormat outputFormatter = new SimpleDateFormat("yyyy-MM-dd");

    try { 
        DBdate = inputFormatter.parse(dateStr); 
        dashDateStr = outputFormatter.format(DBdate); 

        convertFinalDateTV.setText(dashDateStr); 
    } catch (ParseException e ) { 
        e.printStackTrace(); 
    }

With this code, 201274 displays fine as 2012-07-04, but two digit months display incorrectly, 20121016 shows as 2012-01-16 (January 16). The problem is in the MM and dd. I’ve tried yyyy-M-dd as the output date format, but that shows 2012-1-16 (again, January 16).

Do I have to somehow isolate the M value and do that month + 1 thing? If so how would that be written, and where would it go?

I don’t want to have to re-write the dates in the database to 20120704 for July 4, 2012, I’d like to be able to fix it in code.

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

    Your problem isn’t that the input formatter should always be yyyyMMdd but that sometimes it should be yyyyMMdd

    in the case of 201274 then an input format of MM won’t apply but in the case of 20121016 then it will.

    You’ll need to add some logic parsing the length of the input and choosing the appropriate formatter.

    Before I could suggest some logic I’d need to ask two questions

    1. How do you represent 2012-10-01 in the database? I guess that it’s 2012101 in which case…
    2. How do you distinguish between 2012111 and 2012111? i.e. 2012-11-01 and 2012-01-11
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making Android app that has this database in it: public void onCreate(SQLiteDatabase db)
I am looking into writing an Android app that has a database of approximately
My Android App has a products table in an SQLite database that comes pre-populated
I have a superclass for my Activities (WhereWolfActivity) in my Android app that has
I have an android app that has various activities. for example there is a
I'm working on an Android app that has to store data in a database.
I`ve an app that use sqlite for storage. In this database I have a
I am working on an android app and have to use remote database for
I have an Android application that uses the Android database to create tables and
I have a table in SQLite database of Android which has a column RANK

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.