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


Java DateUtils.DAY_IN_MILLIS屬性代碼示例

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


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

示例1: formatLastUpdated

public static String formatLastUpdated(@NonNull Resources res, @NonNull Date date) {
    long msDiff = Calendar.getInstance().getTimeInMillis() - date.getTime();
    long days   = msDiff / DateUtils.DAY_IN_MILLIS;
    long weeks  = msDiff / (DateUtils.DAY_IN_MILLIS * 7);
    long months = msDiff / (DateUtils.DAY_IN_MILLIS * 30);
    long years  = msDiff / (DateUtils.DAY_IN_MILLIS * 365);

    if (days < 1) {
        return res.getString(R.string.details_last_updated_today);
    } else if (weeks < 1) {
        return res.getQuantityString(R.plurals.details_last_update_days, (int) days, days);
    } else if (months < 1) {
        return res.getQuantityString(R.plurals.details_last_update_weeks, (int) weeks, weeks);
    } else if (years < 1) {
        return res.getQuantityString(R.plurals.details_last_update_months, (int) months, months);
    } else {
        return res.getQuantityString(R.plurals.details_last_update_years, (int) years, years);
    }
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:19,代碼來源:Utils.java

示例2: insertAndLoadNote

private void insertAndLoadNote() {
    NoteDao noteDao = ExampleApp.getDaoSession(this).getNoteDao();
    noteDao.deleteAll();

    Note note = new Note();
    note.setText("some text");
    note.setDate(new Date());
    noteDao.insert(note);

    note.setText("some new text");
    noteDao.update(note);

    Note noteLoaded = noteDao.load(note.getId());

    // load the example inserted on creating the database
    Note noteExample = noteDao.load(1L);

    // query by creation date
    long currentTime = System.currentTimeMillis();
    Date aDayAgo = new Date(currentTime - DateUtils.DAY_IN_MILLIS);
    Date inADay = new Date(currentTime + DateUtils.DAY_IN_MILLIS);
    List<Note> results = noteDao.queryBuilder()
            .where(NoteDao.Properties.Date.gt(aDayAgo), NoteDao.Properties.Date.lt(inADay))
            .build()
            .list();
}
 
開發者ID:greenrobot-team,項目名稱:greenrobot-examples,代碼行數:26,代碼來源:MainActivity.java

示例3: clearCacheFolder

static int clearCacheFolder(final File dir, final int numDays) {

        int deletedFiles = 0;
        if (dir != null && dir.isDirectory()) {
            try {
                for (File child : dir.listFiles()) {

                    //first delete subdirectories recursively
                    if (child.isDirectory()) {
                        deletedFiles += clearCacheFolder(child, numDays);
                    }

                    //then delete the files and subdirectories in this dir
                    //only empty directories can be deleted, so subdirs have been done first
                    if (child.lastModified() < new Date().getTime() - numDays * DateUtils.DAY_IN_MILLIS) {
                        if (child.delete()) {
                            deletedFiles++;
                        }
                    }
                }
            } catch (Exception e) {
                Log.e("Info", String.format("Failed to clean the cache, error %s", e.getMessage()));
            }
        }
        return deletedFiles;
    }
 
開發者ID:Justson,項目名稱:AgentWebX5,代碼行數:26,代碼來源:AgentWebX5Utils.java

示例4: getNetworkStatsHistory

private static NetworkStatsHistory getNetworkStatsHistory(long[] history, int days) {
    if (days > history.length) days = history.length;
    NetworkStatsHistory networkStatsHistory =
            new NetworkStatsHistory(
                    DateUtils.DAY_IN_MILLIS, days, NetworkStatsHistory.FIELD_RX_BYTES);

    DataReductionProxySettings config = DataReductionProxySettings.getInstance();
    long time = config.getDataReductionLastUpdateTime() - days * DateUtils.DAY_IN_MILLIS;
    for (int i = history.length - days, bucket = 0; i < history.length; i++, bucket++) {
        NetworkStats.Entry entry = new NetworkStats.Entry();
        entry.rxBytes = history[i];
        long startTime = time + (DateUtils.DAY_IN_MILLIS * bucket);
        // Spread each day's record over the first hour of the day.
        networkStatsHistory.recordData(
                startTime, startTime + DateUtils.HOUR_IN_MILLIS, entry);
    }
    return networkStatsHistory;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:18,代碼來源:DataReductionPreferences.java

示例5: clearCacheFolder

static int clearCacheFolder(final File dir, final int numDays) {

        int deletedFiles = 0;
        if (dir != null) {
            Log.i("Info", "dir:" + dir.getAbsolutePath());
        }
        if (dir != null && dir.isDirectory()) {
            try {
                for (File child : dir.listFiles()) {

                    //first delete subdirectories recursively
                    if (child.isDirectory()) {
                        deletedFiles += clearCacheFolder(child, numDays);
                    }

                    //then delete the files and subdirectories in this dir
                    //only empty directories can be deleted, so subdirs have been done first
                    if (child.lastModified() < new Date().getTime() - numDays * DateUtils.DAY_IN_MILLIS) {
                        Log.i(TAG, "file name:" + child.getName());
                        if (child.delete()) {
                            deletedFiles++;
                        }
                    }
                }
            } catch (Exception e) {
                Log.e("Info", String.format("Failed to clean the cache, error %s", e.getMessage()));
            }
        }
        return deletedFiles;
    }
 
開發者ID:Justson,項目名稱:AgentWeb,代碼行數:30,代碼來源:AgentWebUtils.java

示例6: clearCacheFolder

public static int clearCacheFolder(final File dir,
                                   final int numDays) {

    int deletedFiles = 0;
    if (dir != null && dir.isDirectory()) {
        try {
            for (File child : dir.listFiles()) {

                // first delete subdirectories recursively
                if (child.isDirectory()) {
                    deletedFiles += clearCacheFolder(child,
                            numDays);
                }

                // then delete the files and subdirectories in this dir
                // only empty directories can be deleted, so subDirs have
                // been done first
                if (child.lastModified() < new Date().getTime() - numDays * DateUtils.DAY_IN_MILLIS) {
                    if (child.delete()) {
                        deletedFiles++;
                    }
                }
            }
        } catch (Exception e) {
            Log.e(e, "clearCacheFolder");
        }
    }
    return deletedFiles;
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:29,代碼來源:FileUtil.java

示例7: setReductionStats

/**
 * Sets the current statistics for viewing. These include the original total daily size of
 * received resources before compression, and the actual total daily size of received
 * resources after compression. The last update time is specified in milliseconds since the
 * epoch.
 * @param lastUpdateTimeMillis The last time the statistics were updated.
 * @param networkStatsHistoryOriginal The history of original content lengths.
 * @param networkStatsHistoryReceived The history of received content lengths.
 */
public void setReductionStats(
        long lastUpdateTimeMillis,
        NetworkStatsHistory networkStatsHistoryOriginal,
        NetworkStatsHistory networkStatsHistoryReceived) {
    mCurrentTime = lastUpdateTimeMillis;
    mRightPosition = mCurrentTime + DateUtils.HOUR_IN_MILLIS
            - TimeZone.getDefault().getOffset(mCurrentTime);
    mLeftPosition = lastUpdateTimeMillis - DateUtils.DAY_IN_MILLIS * DAYS_IN_CHART;
    mOriginalNetworkStatsHistory = networkStatsHistoryOriginal;
    mReceivedNetworkStatsHistory = networkStatsHistoryReceived;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:20,代碼來源:DataReductionStatsPreference.java

示例8: formatDuring

/**
 * 將給定的毫秒數轉換為可讀字符串
 *
 * @param milliseconds 待轉換的毫秒數
 * @return 該毫秒數轉換為 * days * hours * minutes * seconds 後的格式
 */
public static String formatDuring(long milliseconds) {
    long days = milliseconds / DateUtils.DAY_IN_MILLIS;
    long hours = (milliseconds % DateUtils.DAY_IN_MILLIS) / DateUtils.HOUR_IN_MILLIS;
    long minutes = (milliseconds % DateUtils.HOUR_IN_MILLIS) / DateUtils.MINUTE_IN_MILLIS;
    long seconds = (milliseconds % DateUtils.MINUTE_IN_MILLIS) / DateUtils.SECOND_IN_MILLIS;
    return days + " days " + hours + " hours " + minutes + " minutes "
           + seconds + " seconds ";
}
 
開發者ID:starcor-company,項目名稱:starcor.xul,代碼行數:14,代碼來源:XulSystemUtil.java

示例9: convertSecondsToDays

/**
 * Converter segundos em dias
 */
public static double convertSecondsToDays(double seconds) {
    return seconds > 0.00 ? (seconds * 1000.00) / DateUtils.DAY_IN_MILLIS : 0.00;
}
 
開發者ID:brolam,項目名稱:OpenHomeAnalysis,代碼行數:6,代碼來源:OhaHelper.java

示例10: updateView

private void updateView() {
    if (!isAdded())
        return;

    final boolean showProgress;

    if (blockchainState != null && blockchainState.bestChainDate != null) {
        final long blockchainLag = System.currentTimeMillis() - blockchainState.bestChainDate.getTime();
        final boolean blockchainUptodate = blockchainLag < BLOCKCHAIN_UPTODATE_THRESHOLD_MS;
        final boolean noImpediments = blockchainState.impediments.isEmpty();

        showProgress = !(blockchainUptodate || !blockchainState.replaying);

        final String downloading = getString(noImpediments ? R.string.blockchain_state_progress_downloading
                : R.string.blockchain_state_progress_stalled);

        if (blockchainLag < 2 * DateUtils.DAY_IN_MILLIS) {
            final long hours = blockchainLag / DateUtils.HOUR_IN_MILLIS;
            viewProgress.setText(getString(R.string.blockchain_state_progress_hours, downloading, hours));
        } else if (blockchainLag < 2 * DateUtils.WEEK_IN_MILLIS) {
            final long days = blockchainLag / DateUtils.DAY_IN_MILLIS;
            viewProgress.setText(getString(R.string.blockchain_state_progress_days, downloading, days));
        } else if (blockchainLag < 90 * DateUtils.DAY_IN_MILLIS) {
            final long weeks = blockchainLag / DateUtils.WEEK_IN_MILLIS;
            viewProgress.setText(getString(R.string.blockchain_state_progress_weeks, downloading, weeks));
        } else {
            final long months = blockchainLag / (30 * DateUtils.DAY_IN_MILLIS);
            viewProgress.setText(getString(R.string.blockchain_state_progress_months, downloading, months));
        }
    } else {
        showProgress = false;
    }

    if (!showProgress) {
        viewBalance.setVisibility(View.VISIBLE);

        if (!showLocalBalance)
            viewBalanceLocal.setVisibility(View.GONE);

        if (balance != null) {
            viewBalanceBtc.setVisibility(View.VISIBLE);
            viewBalanceBtc.setFormat(config.getFormat());
            viewBalanceBtc.setAmount(balance);

            if (showLocalBalance) {
                if (exchangeRate != null) {
                    final Fiat localValue = exchangeRate.rate.coinToFiat(balance);
                    viewBalanceLocal.setVisibility(View.VISIBLE);
                    viewBalanceLocal.setFormat(Constants.LOCAL_FORMAT.code(0,
                            Constants.PREFIX_ALMOST_EQUAL_TO + exchangeRate.getCurrencyCode()));
                    viewBalanceLocal.setAmount(localValue);
                    viewBalanceLocal.setTextColor(getResources().getColor(R.color.fg_less_significant));
                } else {
                    viewBalanceLocal.setVisibility(View.INVISIBLE);
                }
            }
        } else {
            viewBalanceBtc.setVisibility(View.INVISIBLE);
        }

        if (balance != null && balance.isGreaterThan(TOO_MUCH_BALANCE_THRESHOLD)) {
            viewBalanceWarning.setVisibility(View.VISIBLE);
            viewBalanceWarning.setText(R.string.wallet_balance_fragment_too_much);
        } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
            viewBalanceWarning.setVisibility(View.VISIBLE);
            viewBalanceWarning.setText(R.string.wallet_balance_fragment_insecure_device);
        } else {
            viewBalanceWarning.setVisibility(View.GONE);
        }

        viewProgress.setVisibility(View.GONE);
    } else {
        viewProgress.setVisibility(View.VISIBLE);
        viewBalance.setVisibility(View.INVISIBLE);
    }
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:76,代碼來源:WalletBalanceFragment.java


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