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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:30:37+00:00 2026-06-15T03:30:37+00:00

I am developing an app which is similiar to android facebook app. I got

  • 0

I am developing an app which is similiar to android facebook app.

I got an created time field from facebook app

  "created_time": "2012-11-28T12:53:40+0000",

So, how can I convert this into date format of android facebook app,like

2hours ago,
yesterday at 5:30pm etc
  • 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-15T03:30:39+00:00Added an answer on June 15, 2026 at 3:30 am

    Try this:

    String getCreatedTime = JOConversations.getString("created_time");
    long finalTimeStamp = Long.valueOf(getCreatedTime);
    SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssZ");
    
    SimpleDateFormat formatter = getDateFormat();
    ParsePosition pos = new ParsePosition(0);
    long then = formatter.parse(timestamp, pos).getTime();
    long now = new Date().getTime();
    
    long seconds = (now - then)/1000;
    long minutes = seconds/60;
    long hours = minutes/60;
    long days = hours/24;
    
    String friendly = null;
    long num = 0;
    if (days > 0) {
        num = days;
        friendly = days + " day";
    } else if (hours > 0) {
        num = hours;
        friendly = hours + " hour";
    } else if (minutes > 0) {
        num = minutes;
        friendly = minutes + " minute";
    } else {
        num = seconds;
        friendly = seconds + " second";
    }
    if (num > 1) {
        friendly += "s";
    }
    String postTimeStamp = friendly.toUpperCase() + " AGO";
    

    And a helper method for this bit here: SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssZ"); is

    private static SimpleDateFormat getDateFormat() {
        return new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssZ");
    }
    

    I derived this code block from the StreamRenderer.java in the Facebook SDK exmples on GitHub here: https://github.com/facebook/facebook-android-sdk/blob/master/examples/stream/src/com/facebook/stream/StreamRenderer.java (Check Line No. 380 onwards)

    It does not deal with the scenario yesterday at 5:30pm. But this should get you started.

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

Sidebar

Related Questions

I'm currently developing an Android app, which loads events from a server using JSON
I'm developing an app which uses RapidMiner for classification. I train the classifier time
I am currently developing an app which will be on Android Market. How can
i am developing app that would receive data from server any time. i have
I am developing a app in android .... which need a code snippet to
I'm developing an Android App which, amongst other things, displays the result of a
Im developing an App which is going to be used on Samsung Galaxy SII
I am developing an app which draws more or less a two-dimensional matrix of
I'm developing an app which has a large amount of related form data to
I am developing an app which requires the phone to ring or make some

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.