当前位置: 首页>>代码示例>>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;未经允许,请勿转载。