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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:35:49+00:00 2026-05-27T00:35:49+00:00

I am new starter android. I have simple question. When I choose date through

  • 0

I am new starter android.
I have simple question. When I choose date through datePickerDialog and press confirm button, I want to store the date as date format instead of string.
How can I store the date format?

private static final String DATABASE_CREATE = 
"create table fridge_table (_id integer primary key autoincrement, "+
"category text not null, name texct not null, expired_date text not null);";

public void onCreate(SQLiteDatabase db)
{
  db.execSQL(DATABASE_CREATE);
}

How can I change expired_Date field? some of people said using long, or date.
I am wondering how to store in sqlite.

What I am trying to convert date, I want to set the alarm through this field.
Could you help me? and if you have any example, please give me some of example.

  • 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-27T00:35:49+00:00Added an answer on May 27, 2026 at 12:35 am

    You can use Calendar object then.

    You can save time like:

    Calendar cal=Calendar.getInstance();
    //set date,month,year,time etc. according to your need to cal object
    //add expired_date's value as cal.getTimeInMillis()
    

    You can also retrieve the same using:

    long date=cursor.getLong(cursor.getColumnIndex("expired_date"));
    Calendar cal=Calendar.getInstance();
    cal.clear();
    cal.setTimeInMillis(date);
    // you can use any format to display this time using String.format() method.
    

    For various date format options,visit http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Formatter.html

    EDIT :

    For example:

    Calendar cal=Calendar.getInstance();
    String date_time=String.format("%1$te %1$tB %1$tY,%1$tI:%1$tM:%1$tS %1$Tp",cal);
    Toast.makeText(getApplicationContext(),date_time,Toast.LENGTH_SHORT).show();
    //this will show a toast containing current date and time in format "23 January 2010,12:30:15 pm"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Android, I've followed the hello world tutorial through and have a
I'm new to android developing, so i apologise if this is a simple/noob-ish question,
I'm quite new to Android development (started 2 days ago) and have been through
I have starter new System.Diagnostics.Process and it launchs FireFox. How can I obtain the
Before I delve into it, I'm very new to Android and I have just
I have just started with android in Eclipse and now i want to do
Background: I have started Android recently. I want to make an application for Android
I have created a button in my screen's XML like this: <Button android:text=Lets Get
I am a new game developer and have started developing game for android. I
I have a simple Activity that uses a android:theme=@android:style/Theme.Dialog in the manifest. My activity

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.