Java Code Examples for android.text.format.DateUtils#MINUTE_IN_MILLIS
The following examples show how to use
android.text.format.DateUtils#MINUTE_IN_MILLIS .
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: TimeUtils.java From OmniList with GNU Affero General Public License v3.0 | 6 votes |
/** * 录音时间的格式化 * * @param recordMillis 录音时间(毫秒) * @return 时间字符串 */ public static String getRecordTime(long recordMillis) { int minute = (int) (recordMillis / DateUtils.MINUTE_IN_MILLIS); int seconds = (int) ((recordMillis % DateUtils.MINUTE_IN_MILLIS ) / 1000); String time = ""; if (minute < 10) { time += "0" + minute; } else { time += minute; } time += ":"; if (seconds < 10) { time += "0" + seconds; } else { time += seconds; } return time; }
Example 2
Source File: AppUtils.java From materialistic with Apache License 2.0 | 6 votes |
public static String getAbbreviatedTimeSpan(long timeMillis) { long span = Math.max(System.currentTimeMillis() - timeMillis, 0); if (span >= DateUtils.YEAR_IN_MILLIS) { return (span / DateUtils.YEAR_IN_MILLIS) + ABBR_YEAR; } if (span >= DateUtils.WEEK_IN_MILLIS) { return (span / DateUtils.WEEK_IN_MILLIS) + ABBR_WEEK; } if (span >= DateUtils.DAY_IN_MILLIS) { return (span / DateUtils.DAY_IN_MILLIS) + ABBR_DAY; } if (span >= DateUtils.HOUR_IN_MILLIS) { return (span / DateUtils.HOUR_IN_MILLIS) + ABBR_HOUR; } return (span / DateUtils.MINUTE_IN_MILLIS) + ABBR_MINUTE; }
Example 3
Source File: TimeUtils.java From OmniList with GNU Affero General Public License v3.0 | 6 votes |
public static String getTimeLength(Context context, long startMillis, long endMillis){ if (endMillis < startMillis) return "--"; long timeSpan = endMillis - startMillis; int days = (int) (timeSpan / DateUtils.DAY_IN_MILLIS); int hours = (int) (timeSpan % DateUtils.DAY_IN_MILLIS / DateUtils.HOUR_IN_MILLIS); int minutes = (int) (timeSpan % DateUtils.DAY_IN_MILLIS % DateUtils.HOUR_IN_MILLIS / DateUtils.MINUTE_IN_MILLIS); StringBuilder sb = new StringBuilder(); if (days != 0){ sb.append(String.valueOf(days)); } if (hours != 0){ sb.append(String.valueOf(hours)); } if (minutes != 0){ sb.append(String.valueOf(minutes)); } return sb.toString(); }
Example 4
Source File: DateTimeUtils.java From Qiitanium with MIT License | 6 votes |
public static String timeAgo(Date d) { final long referenceTime = d.getTime(); final long nowTime = System.currentTimeMillis(); final long diffTime = Math.abs(nowTime - referenceTime); if (diffTime > DateUtils.WEEK_IN_MILLIS) { return format(d, TIMEFORMAT_DEFAULT); } else if (diffTime > DateUtils.DAY_IN_MILLIS) { return String.format(TIMEAGO_DAYS_AGO, diffTime / DateUtils.DAY_IN_MILLIS); } else if (diffTime > DateUtils.HOUR_IN_MILLIS) { return String.format(TIMEAGO_HOURS_AGO, diffTime / DateUtils.HOUR_IN_MILLIS); } else if (diffTime > DateUtils.MINUTE_IN_MILLIS) { return String.format(TIMEAGO_MINUTES_AGO, diffTime / DateUtils.MINUTE_IN_MILLIS); } else { return TIMEAGO_JUST_NOW; } }
Example 5
Source File: LrcEntry.java From YCAudioPlayer with Apache License 2.0 | 6 votes |
private static List<LrcEntry> parseLine(String line) { if (TextUtils.isEmpty(line)) { return null; } line = line.trim(); Matcher lineMatcher = Pattern.compile("((\\[\\d\\d:\\d\\d\\.\\d\\d\\])+)(.+)").matcher(line); if (!lineMatcher.matches()) { return null; } String times = lineMatcher.group(1); String text = lineMatcher.group(3); List<LrcEntry> entryList = new ArrayList<>(); Matcher timeMatcher = Pattern.compile("\\[(\\d\\d):(\\d\\d)\\.(\\d\\d)\\]").matcher(times); while (timeMatcher.find()) { long min = Long.parseLong(timeMatcher.group(1)); long sec = Long.parseLong(timeMatcher.group(2)); long mil = Long.parseLong(timeMatcher.group(3)); long time = min * DateUtils.MINUTE_IN_MILLIS + sec * DateUtils.SECOND_IN_MILLIS + mil * 10; entryList.add(new LrcEntry(time, text)); } return entryList; }
Example 6
Source File: CalendarUtils.java From android with MIT License | 5 votes |
/** * Get the current daytime in MilliSeconds, compatible with Intervals * * @return Today's milliseconds (since midnight) */ public static long todayMillis() { final Calendar cal = GregorianCalendar.getInstance(); cal.setTime(new Date()); return cal.get(Calendar.HOUR_OF_DAY) * DateUtils.HOUR_IN_MILLIS + cal.get(Calendar.MINUTE) * DateUtils.MINUTE_IN_MILLIS; }
Example 7
Source File: RelativeTimeTextView.java From v2ex-daily-android with Apache License 2.0 | 5 votes |
public void run() { long difference = Math.abs(System.currentTimeMillis() - mReferenceTime); long interval = DateUtils.MINUTE_IN_MILLIS; if (difference > DateUtils.WEEK_IN_MILLIS) { interval = DateUtils.WEEK_IN_MILLIS; } else if (difference > DateUtils.DAY_IN_MILLIS) { interval = DateUtils.DAY_IN_MILLIS; } else if (difference > DateUtils.HOUR_IN_MILLIS) { interval = DateUtils.HOUR_IN_MILLIS; } updateTextDisplay(); mHandler.postDelayed(this, interval); }
Example 8
Source File: RelativeTimeTextView.java From Tweetin with Apache License 2.0 | 5 votes |
private CharSequence getRelativeTimeDisplayString() { long now = System.currentTimeMillis(); long difference = now - mReferenceTime; return (difference >= 0 && difference<=DateUtils.MINUTE_IN_MILLIS) ? getResources().getString(R.string.tweet_just_now): DateUtils.getRelativeTimeSpanString( mReferenceTime, now, DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE); }
Example 9
Source File: RelativeTimeTextView.java From WaniKani-for-Android with GNU General Public License v3.0 | 5 votes |
@Override public void run() { long difference = Math.abs(System.currentTimeMillis() - mRefTime); long interval = DateUtils.MINUTE_IN_MILLIS; if (difference > DateUtils.WEEK_IN_MILLIS) { interval = DateUtils.WEEK_IN_MILLIS; } else if (difference > DateUtils.DAY_IN_MILLIS) { interval = DateUtils.DAY_IN_MILLIS; } else if (difference > DateUtils.HOUR_IN_MILLIS) { interval = DateUtils.HOUR_IN_MILLIS; } updateTextDisplay(); mHandler.postDelayed(this, interval); }
Example 10
Source File: RelativeTimeTextView.java From Ninja with Apache License 2.0 | 5 votes |
private CharSequence getRelativeTimeDisplayString() { long now = System.currentTimeMillis(); long difference = now - mReferenceTime; return (difference >= 0 && difference<=DateUtils.MINUTE_IN_MILLIS) ? getResources().getString(R.string.android_ago_just_now): DateUtils.getRelativeTimeSpanString( mReferenceTime, now, DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE); }
Example 11
Source File: RelativeTimeTextView.java From WaniKani-for-Android with GNU General Public License v3.0 | 5 votes |
private CharSequence getRelativeTimeDisplayString() { long now = System.currentTimeMillis(); long difference = now - mReferenceTime; return (difference >= 0 && difference <= DateUtils.MINUTE_IN_MILLIS) ? getResources().getString(R.string.just_now) : DateUtils.getRelativeTimeSpanString( mReferenceTime, now, DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE); }
Example 12
Source File: RelativeTimeTextView.java From Ninja with Apache License 2.0 | 5 votes |
@Override public void run() { long difference = Math.abs(System.currentTimeMillis() - mRefTime); long interval = DateUtils.MINUTE_IN_MILLIS; if (difference > DateUtils.WEEK_IN_MILLIS) { interval = DateUtils.WEEK_IN_MILLIS; } else if (difference > DateUtils.DAY_IN_MILLIS) { interval = DateUtils.DAY_IN_MILLIS; } else if (difference > DateUtils.HOUR_IN_MILLIS) { interval = DateUtils.HOUR_IN_MILLIS; } updateTextDisplay(); mHandler.postDelayed(this, interval); }
Example 13
Source File: PlayActivity.java From MeetMusic with Apache License 2.0 | 5 votes |
public static String formatTime(String pattern, long milli) { int m = (int) (milli / DateUtils.MINUTE_IN_MILLIS); int s = (int) ((milli / DateUtils.SECOND_IN_MILLIS) % 60); String mm = String.format(Locale.getDefault(), "%02d", m); String ss = String.format(Locale.getDefault(), "%02d", s); return pattern.replace("mm", mm).replace("ss", ss); }
Example 14
Source File: LockActivity.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void doCreateView(Bundle savedInstanceState) { lockPreferences = LockPreferences.getInstance(); psdFreezeLength = lockPreferences.getPasswordFreezeTime() * DateUtils.MINUTE_IN_MILLIS; savedPassword = lockPreferences.getPassword(); configSystemUI(); configViews(); checkPassword(); }
Example 15
Source File: MusicInfoActivity.java From YCAudioPlayer with Apache License 2.0 | 5 votes |
private String formatTime(String pattern, long milli) { int m = (int) (milli / DateUtils.MINUTE_IN_MILLIS); int s = (int) ((milli / DateUtils.SECOND_IN_MILLIS) % 60); String mm = String.format(Locale.getDefault(), "%02d", m); String ss = String.format(Locale.getDefault(), "%02d", s); return pattern.replace("mm", mm).replace("ss", ss); }
Example 16
Source File: TextUtils.java From v2ex-daily-android with Apache License 2.0 | 5 votes |
public static CharSequence getRelativeTimeDisplayString(Context context, long referenceTime) { long now = System.currentTimeMillis(); long difference = now - referenceTime; return (difference >= 0 && difference<= DateUtils.MINUTE_IN_MILLIS) ? context.getResources().getString(R.string.just_now): DateUtils.getRelativeTimeSpanString( referenceTime, now, DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE); }
Example 17
Source File: TimeUtils.java From OmniList with GNU Affero General Public License v3.0 | 4 votes |
public static int getTimeInMillis(int hour, int minute){ return (int) (DateUtils.HOUR_IN_MILLIS * hour + DateUtils.MINUTE_IN_MILLIS * minute); }
Example 18
Source File: TimeUtils.java From OmniList with GNU Affero General Public License v3.0 | 4 votes |
public static int getMinute(int timeMillis) { return (int) (timeMillis % DateUtils.HOUR_IN_MILLIS / DateUtils.MINUTE_IN_MILLIS); }
Example 19
Source File: TweetDateUtilsTest.java From twitter-kit-android with Apache License 2.0 | 4 votes |
@Test public void testGetRelativeTimeString_minutesAgo() { final long twoMinutesAgo = NOW_IN_MILLIS - DateUtils.MINUTE_IN_MILLIS * 2; assertEquals("2m", TweetDateUtils.getRelativeTimeString(resources, NOW_IN_MILLIS, twoMinutesAgo)); }
Example 20
Source File: RestrInterval.java From android with MIT License | 2 votes |
/** * Get TimeMax value, in milliseconds * * @return long TimeMax millis */ public long getTimeMaxMillis() { return timeMax * DateUtils.MINUTE_IN_MILLIS; }