Skip to content

Takes date Strings returned by the Twitter API and spits out relative date Strings formatted for display in the same style that Twitter uses (e.g. "4m", "6d", "22 Jun", "24 May 2012" depending on relative time difference).

Notifications You must be signed in to change notification settings

ravimultani38/TimeFormatter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

TimeFormatter

Given a date String of the format given by the Twitter API, returns a display-formatted String representing the relative time difference, e.g. "2m", "6d", "23 May", "1 Jan 2014" depending on how great the time difference between now and the given date is. This, as of 2016-06-29, matches the behavior of the official Twitter app.

Usage

Just copy TimeFormatter.java into a Java class in your project, then call

String formattedTime = TimeFormatter.getTimeDifference(String dateString);

to turn a Twitter API-returned dateString into a String properly formatted for display that represents the relative time difference (matching Twitter's behavior when viewing a list of Tweets), or

String formattedAbsoluteTime = TimeFormatter.getTimeStamp(String rawJsonDate);

to turn a Twitter API-returned dateString into a String formatted like that of the official Twitter app's detailed Tweet view.

Contributors

  • Kristina Shia
  • Evan Wildenhain
  • David Gisser

About

Takes date Strings returned by the Twitter API and spits out relative date Strings formatted for display in the same style that Twitter uses (e.g. "4m", "6d", "22 Jun", "24 May 2012" depending on relative time difference).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%