All Projects → damien5314 → Timesincetextview

damien5314 / Timesincetextview

Licence: apache-2.0
Android TextView for displaying the time since a date

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Timesincetextview

Graphql Java Datetime
GraphQL ISO Date is a set of RFC 3339 compliant date/time scalar types to be used with graphql-java.
Stars: ✭ 89 (-17.59%)
Mutual labels:  time
Stopwatch
⏱️ Single-header C++11 RDTSCP clock and timing utilities released into the public domain.
Stars: ✭ 96 (-11.11%)
Mutual labels:  time
Timeoverflow
🏦 ⌛ A time banking system
Stars: ✭ 100 (-7.41%)
Mutual labels:  time
Js Joda
🕑 Immutable date and time library for javascript
Stars: ✭ 1,298 (+1101.85%)
Mutual labels:  time
Brein Time Utilities
Library which contains several time-dependent data and index structures (e.g., IntervalTree, BucketTimeSeries), as well as algorithms.
Stars: ✭ 94 (-12.96%)
Mutual labels:  time
Cron4s
Cross-platform CRON expression parsing for Scala
Stars: ✭ 99 (-8.33%)
Mutual labels:  time
Rapidfloatingactionbutton
Quick solutions for Floating Action Button,RapidFloatingActionButton(RFAB)
Stars: ✭ 1,289 (+1093.52%)
Mutual labels:  custom-view
Time Stamp
Get a formatted timestamp. Used in gulp, assemble, generate, and many others.
Stars: ✭ 104 (-3.7%)
Mutual labels:  time
Meter Number Picker
The android library that provides a simple and customizable NumberPicker styled as meter.
Stars: ✭ 96 (-11.11%)
Mutual labels:  custom-view
Kairos
A non date-based time calculator
Stars: ✭ 100 (-7.41%)
Mutual labels:  time
Tinytime
⏰ A straightforward date and time formatter in <1kb
Stars: ✭ 1,313 (+1115.74%)
Mutual labels:  time
Luatz
Time, Date and Timezone library for lua
Stars: ✭ 92 (-14.81%)
Mutual labels:  time
Date And Time
A Minimalist DateTime utility for Node.js and the browser
Stars: ✭ 99 (-8.33%)
Mutual labels:  time
Timezone Support
Lightweight time zone support for your applications or other date libraries.
Stars: ✭ 90 (-16.67%)
Mutual labels:  time
Mkloader
Beautiful and smooth custom loading views
Stars: ✭ 1,377 (+1175%)
Mutual labels:  custom-view
News Record
目前主要维护经济学人【The Economist】、纽约客【The NewYorker】和时代杂志【Time】
Stars: ✭ 87 (-19.44%)
Mutual labels:  time
Redux Time
∞ High-performance declarative JS animation library for building games, data-viz experiences, and more w/ React, ThreeJS, Inferno, SnabbDOM and others...
Stars: ✭ 99 (-8.33%)
Mutual labels:  time
Hyperapp Fx
Effects for use with Hyperapp
Stars: ✭ 105 (-2.78%)
Mutual labels:  time
Consecutivescroller
ConsecutiveScrollerLayout是Android下支持多个滑动布局(RecyclerView、WebView、ScrollView等)和普通控件(TextView、ImageView、LinearLayou、自定义View等)持续连贯滑动的容器,它使所有的子View像一个整体一样连续顺畅滑动。并且支持布局吸顶功能。
Stars: ✭ 1,383 (+1180.56%)
Mutual labels:  custom-view
Dateparse
GoLang Parse many date strings without knowing format in advance.
Stars: ✭ 1,365 (+1163.89%)
Mutual labels:  time

TimeSinceTextView

This is a subclass of android.widget.TextView that exposes a method setDate() which accepts a long Unix timestamp or java.util.Date. The view converts the date into a String which describes the date in terms of time since that timestamp. For example, if the current timestamp is Unix 1453503166 and we call timeSinceTextView.setDate(1453503116), "50 seconds ago" is displayed.

Changelog

Javadoc

Comparison to DateUtils.getRelativeTimeSpanString

I actually wrote this library before I knew about DateUtils.getRelativeTimeSpanString, but the output is actually quite a bit different. The DateUtils implementation should return localized text and allows for customizable flags. See here for a comparison of the output of different time stamps.

Usage

Simply declare a TimeSinceTextView in XML or create one in code.

<com.ddiehl.timesincetextview.TimeSinceTextView
  android:id="@+id/timestamp"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" />

Then call setDate(Date) or setDate(long) with a Unix timestamp, and the text will be automatically generated and set to the view.

((TimeSinceTextView) findViewById(R.id.timestamp)).setDate(1452827942);

To get an abbreviated form of the converted text, add app:abbreviated="true" to your XML layout.

<com.ddiehl.timesincetextview.TimeSinceTextView
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  app:tstv_abbreviated="true" />

The class TimeSince also contains static methods which can be used to retrieve a relative timestamp string without an instance of TimeSinceTextView.

Add to your project

Release

repositories {
    maven { url "https://jitpack.io" }
}
dependencies {
  compile 'com.github.damien5314:TimeSinceTextView:1.+'
}

Screenshot

Contributions

Pull requests are welcome, in particular in would be nice to have strings.xml translated into as many languages as possible.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].