當前位置: 首頁>>代碼示例>>Java>>正文


Java DateUtils.formatElapsedTime方法代碼示例

本文整理匯總了Java中android.text.format.DateUtils.formatElapsedTime方法的典型用法代碼示例。如果您正苦於以下問題:Java DateUtils.formatElapsedTime方法的具體用法?Java DateUtils.formatElapsedTime怎麽用?Java DateUtils.formatElapsedTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.text.format.DateUtils的用法示例。


在下文中一共展示了DateUtils.formatElapsedTime方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setPGTime

import android.text.format.DateUtils; //導入方法依賴的package包/類
private void setPGTime(int progress) {
    try {
        String timeString = "00.00";
        int linePG = 0;
        currentSong = streamingManager.getCurrentAudio();
        if (currentSong != null && progress != Long.parseLong(currentSong.getMediaDuration())) {
            timeString = DateUtils.formatElapsedTime(progress / 1000);
            Long audioDuration = Long.parseLong(currentSong.getMediaDuration());
            linePG = (int) (((progress / 1000) * 100) / audioDuration);
        }
        time_progress_bottom.setText(timeString);
        time_progress_slide.setText(timeString);
        lineProgress.setLineProgress(linePG);
    } catch (NumberFormatException e) {
        e.printStackTrace();
    }
}
 
開發者ID:dibakarece,項目名稱:DMAudioStreamer,代碼行數:18,代碼來源:MusicActivity.java

示例2: formatSeconds

import android.text.format.DateUtils; //導入方法依賴的package包/類
public static String formatSeconds(long seconds) {
    /* Takes number of seconds and returns a String with format HH:MM. */
    String timeString = DateUtils.formatElapsedTime(seconds);
    //If the time is less than an hour, then add "00:" to the beginning:
    if (seconds < 3600) timeString = "00:" + timeString;
    //Otherwise, if the time is less than 10 hours, then add "0" to the beginning:
    else if (seconds < 36000) timeString = "0" + timeString;
    //Removes seconds from time, because it's unneeded information
    return timeString.substring(0, timeString.length()-3);
}
 
開發者ID:brianjaustin,項目名稱:permitlog-android,代碼行數:11,代碼來源:ElapsedTime.java

示例3: setMaxTime

import android.text.format.DateUtils; //導入方法依賴的package包/類
private void setMaxTime() {
    try {
        String timeString = DateUtils.formatElapsedTime(Long.parseLong(currentSong.getMediaDuration()));
        time_total_bottom.setText(timeString);
        time_total_slide.setText(timeString);
    } catch (NumberFormatException e) {
        e.printStackTrace();
    }
}
 
開發者ID:dibakarece,項目名稱:DMAudioStreamer,代碼行數:10,代碼來源:MusicActivity.java

示例4: formatTime

import android.text.format.DateUtils; //導入方法依賴的package包/類
private String formatTime(String duration) {
    try {
        long dur = Long.valueOf(duration);
        return DateUtils.formatElapsedTime(dur);
    } catch (NumberFormatException e) {
        return duration;
    }
}
 
開發者ID:mingdroid,項目名稱:tumbviewer,代碼行數:9,代碼來源:PhotoPostVH.java

示例5: getFormatedDuration

import android.text.format.DateUtils; //導入方法依賴的package包/類
public String getFormatedDuration(){
    if(!TextUtils.isEmpty(duration)){
        long time=Long.parseLong(duration);
        return DateUtils.formatElapsedTime(time/1000);
    }
    return null;
}
 
開發者ID:vpaliyX,項目名稱:Melophile,代碼行數:8,代碼來源:Track.java

示例6: onBindViewHolder

import android.text.format.DateUtils; //導入方法依賴的package包/類
@Override
public void onBindViewHolder(@NonNull final TwoLinesViewHolder holder,
                             @NonNull final Cursor cursor, final int position) {
    final SpannableStringBuilder primary = new SpannableStringBuilder();
    final String cachedName = cursor.getString(cursor.getColumnIndexOrThrow(CallLog.Calls.CACHED_NAME));
    final String number = cursor.getString(cursor.getColumnIndexOrThrow(CallLog.Calls.NUMBER));
    SpannableStringBuilderCompat.append(primary, (cachedName != null ? cachedName : number),
            new StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    primary.append(" ");

    final long duration = cursor.getLong(cursor.getColumnIndexOrThrow(CallLog.Calls.DURATION));
    if (duration > 0) {
        final CharSequence formattedDuration = DateUtils.formatElapsedTime(duration);
        primary.append(formattedDuration);
    }

    holder.setText1(primary);

    final SpannableStringBuilder summary = new SpannableStringBuilder();
    final int type = cursor.getInt(cursor.getColumnIndexOrThrow(CallLog.Calls.TYPE));
    switch (type) {
        case CallLog.Calls.INCOMING_TYPE:
            SpannableStringBuilderCompat.append(summary, "←", new ForegroundColorSpan(Color.BLUE),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            summary.append(" ");
            break;

        case CallLog.Calls.OUTGOING_TYPE:
            SpannableStringBuilderCompat.append(summary, "→", new ForegroundColorSpan(Color.GREEN),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            summary.append(" ");
            break;

        case CallLog.Calls.MISSED_TYPE:
        case CallLog.Calls.REJECTED_TYPE:
            SpannableStringBuilderCompat.append(summary, "☇", new ForegroundColorSpan(Color.RED),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            summary.append(" ");
            break;

        case CallLog.Calls.BLOCKED_TYPE:
            SpannableStringBuilderCompat.append(summary, "☓", new ForegroundColorSpan(Color.BLACK),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            summary.append(" ");
            break;
    }

    final long date = cursor.getLong(cursor.getColumnIndexOrThrow(CallLog.Calls.DATE));
    final CharSequence relativeDate = DateUtils.getRelativeTimeSpanString(date,
            System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS);
    summary.append(relativeDate);

    holder.setText2(summary);
}
 
開發者ID:GlobusLTD,項目名稱:recyclerview-android,代碼行數:55,代碼來源:CallsAdapter.java

示例7: formatMillis

import android.text.format.DateUtils; //導入方法依賴的package包/類
/**
 * Formats time from milliseconds to hh:mm:ss string format.
 */
public static String formatMillis(int millis) {
    return DateUtils.formatElapsedTime(millis/1000);
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:7,代碼來源:Utils.java


注:本文中的android.text.format.DateUtils.formatElapsedTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。