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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:49:21+00:00 2026-06-10T16:49:21+00:00

I have a ListView that users will put comment in. When they hit submit

  • 0

I have a ListView that users will put comment in. When they hit “submit” attached to an EditText box, the new comment goes into a MySQL database along with the current time.

I’d like the comments to appear in the listview with dates similar to Youtube formatting. For example: “10 seconds ago”, “1 day ago”, “52 days ago”.

Would I use the Calendar object, SimpleDateFormat, something else?

Also, how would I store the date in the datebase? I am assuming something easily convertible like the UNIX date stamp maybe. And then would it be in the ArrayAdapter where I dynamically change the date based on the current time?

  • 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-10T16:49:22+00:00Added an answer on June 10, 2026 at 4:49 pm

    To get this you need to calculate the difference between your timestamp and current timestamp (keep them in milliseconds for simplicity). The result will be number of milliseconds “ago”. Then use simple math like subtraction and division and you can get number of minutes, days, weeks and whatever-you-want.

    EDIT: I use this:

    public static final long MILLIS_PER_SECOND  = 1000;
    public static final long MILLIS_PER_MINUTE  = (MILLIS_PER_SECOND * 60);
    public static final long MILLIS_PER_HOUR    = (MILLIS_PER_MINUTE * 60);
    public static final long MILLIS_PER_DAY     = (MILLIS_PER_HOUR * 24);
    public static final long MILLIS_PER_WEEK    = (MILLIS_PER_DAY * 7);
    public static final long MILLIS_PER_MONTH   = (MILLIS_PER_DAY * 30);
    public static final long MILLIS_PER_YEAR    = (MILLIS_PER_MONTH * 12);
    

    Note that is is not 100% correct as I (intentionally, for simplicy) made false assumption month is always 30 days long, which also influences MILLIS_PER_YEAR. But I do not really care – it’s not rocket science I use these for. But you may reduce the impact by setting MILLIS_PER_YEAR this way:

    public static final long MILLIS_PER_YEAR = (MILLIS_PER_DAY * (7*31 + 4*30 + 28));
    

    28 is for February, in this case you only be 1 day off on leaps years, instead of 5 days as in former version.

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

Sidebar

Related Questions

I have a layout that uses an EditText to let users search a database
I have a ListView that will allow the user to long-press an item to
I'm using the new ASP.Net ListView control to list database items that will be
I have a ListView that is dynamic and will constantly change. The user selects
I'm creating a search bar that will search the content of listview .I have
I have ListView that uses a GridView to display several columns of data. Two
I have ListView that has the following EditItemTemplate: <EditItemTemplate> <tr style=> <td> <asp:LinkButton ID=UpdateButton
I have a ListView that shows around 300 items. When something is changed and
I have a listview that highlights a row when you mouseover it with the
I have a listview that contain several EditTexts created dynamically according to the number

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.