Java Code Examples for android.text.format.DateUtils#formatSameDayTime()
The following examples show how to use
android.text.format.DateUtils#formatSameDayTime() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Util.java From android-testdpc with Apache License 2.0 | 5 votes |
/** * Format a friendly datetime for the current locale according to device policy documentation. * If the timestamp doesn't represent a real date, it will be interpreted as {@code null}. * * @return A {@link CharSequence} such as "12:35 PM today" or "June 15, 2033", or {@code null} * in the case that {@param timestampMs} equals zero. */ public static CharSequence formatTimestamp(long timestampMs) { if (timestampMs == 0) { // DevicePolicyManager documentation describes this timestamp as having no effect, // so show nothing for this case as the policy has not been set. return null; } return DateUtils.formatSameDayTime(timestampMs, System.currentTimeMillis(), DateUtils.FORMAT_SHOW_WEEKDAY, DateUtils.FORMAT_SHOW_TIME); }
Example 2
Source File: SyncDetailCalculations.java From commcare-android with Apache License 2.0 | 5 votes |
public static Pair<Long, String> getLastSyncTimeAndMessage() { CharSequence syncTimeMessage; long lastSyncTime = getLastSyncTime(); if (lastSyncTime == 0) { syncTimeMessage = Localization.get("home.sync.message.last.never"); } else { syncTimeMessage = DateUtils.formatSameDayTime(lastSyncTime, new Date().getTime(), DateFormat.DEFAULT, DateFormat.DEFAULT); } return new Pair<>(lastSyncTime, Localization.get("home.sync.message.last", new String[]{syncTimeMessage.toString()})); }
Example 3
Source File: Utils.java From android-discourse with Apache License 2.0 | 2 votes |
/** * format topics list first post time and last post time * * @param time * @return */ public static CharSequence formatActivityTime(long time) { return DateUtils.formatSameDayTime(time, System.currentTimeMillis(), DateFormat.MEDIUM, DateFormat.MEDIUM); }