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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:50:40+00:00 2026-06-04T07:50:40+00:00

this is my first app and i need to be using dates i want

  • 0

this is my first app and i need to be using dates

i want to use an sqlite database in order to store the current date when a button is clicked

also, when that button is clicked, i want it to show the current date in a textview

now i am a PHP programmer by day, but this is all new to me. i am curious as to whether or not trying to use a unix timestamp (int) is the best solution for this, as that is what i am used to storing my dates with in PHP.

heres an example of what im working on right now in order for it to show the date after the button is clicked. the following code is in my onClick function for the button:

    long currentTimestamp = System.currentTimeMillis();
    Date theDate = new Date(currentTimestamp);
    String showDate = theDate.getDay() + "/" + theDate.getMonth() + "/" + theDate.getYear() + " " + theDate.getHours() + ":" + theDate.getMinutes();

i starting going at this, however, in the android documentation its telling me that the functions like getDay and getMonth are deprecated and to use the Calendar functions.

now of course i dont want to start using deprecated functions since im all new to this and dont want to get into bad practices, but i read in another stack overflow question that using Calendar is slower than other solutions.

im just looking for answers as to how to go about doing this the most proper and efficient way….thank you.

EDIT:

i just read this question: How to store and get datetime value in SQLite

one of the answers recommends using a unix timestamp which is what i was originally thinking of doing. is there a way i can do this by converting a unix timestamp (long) to a string when i display it and store it, and still use the Calendar functionality?

  • 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-04T07:50:41+00:00Added an answer on June 4, 2026 at 7:50 am

    get current time and convert it to timestamp:

    long dateInMillis = Calendar.getInstance().getTimeInMillis();
    

    convert back:

    Calendar date = Calendar.getInstance();
    date.setTimeInMillis(dateInMillis);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first app with CI and I want to know whether $_POST
I published my first app yesterday evening, and it appears under this url: https://play.google.com/store/apps/details?id=com.appname
This is my first question. I have an app in which i want to
First as a note I am using this plugin in a Rails app. Ok
I have this web app created using MVC3 and need to make a Windows
I'm working on my first app using Core Data and I need to assign
I need to run some database processing when my app first starts once a
Im using ORMLite in my Android app. I need to persist this class, which
This is my first winform app in .NET... I have made a couple of
Okay this is my first WPF app and I am having a hard run

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.