当前位置: 首页>>代码示例>>Java>>正文


Java Period.getDays方法代码示例

本文整理汇总了Java中org.joda.time.Period.getDays方法的典型用法代码示例。如果您正苦于以下问题:Java Period.getDays方法的具体用法?Java Period.getDays怎么用?Java Period.getDays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.joda.time.Period的用法示例。


在下文中一共展示了Period.getDays方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prettifyDuration

import org.joda.time.Period; //导入方法依赖的package包/类
private String prettifyDuration(String duration) {
    PeriodFormatter formatter = new PeriodFormatterBuilder()
            .appendDays().appendSuffix("d")
            .appendHours().appendSuffix(":")
            .appendMinutes().appendSuffix(":")
            .appendSeconds().toFormatter();

    Period p = formatter.parsePeriod(duration);

    String day = context.getResources().getString(R.string.day_short);

    if(p.getDays() > 0) {
        return String.format("%d"+ day + " %dh %dm", p.getDays(), p.getHours(), p.getMinutes());
    } else if (p.getHours() > 0) {
        return String.format(Locale.getDefault(), "%dh %dm", p.getHours(), p.getMinutes());
    } else {
        return String.format(Locale.getDefault(), "%dm", p.getMinutes());
    }
}
 
开发者ID:IMSmobile,项目名称:Fahrplan,代码行数:20,代码来源:ConnectionAdapter.java

示例2: formatIntervalDay

import org.joda.time.Period; //导入方法依赖的package包/类
/**
 * Formats a period similar to Oracle INTERVAL DAY TO SECOND data type.<br>
 * For example, the string "-001 18:25:16.766" defines an interval of - 1 day 18 hours 25 minutes 16 seconds and 766 milliseconds
 */
public static String formatIntervalDay(final Period p) {
  long millis = p.getDays() * (long) DateUtility.daysToStandardMillis + DateUtility.millisFromPeriod(p);

  boolean neg = false;
  if (millis < 0) {
    millis = -millis;
    neg = true;
  }

  final int days = (int) (millis / DateUtility.daysToStandardMillis);
  millis = millis % DateUtility.daysToStandardMillis;

  final int hours  = (int) (millis / DateUtility.hoursToMillis);
  millis     = millis % DateUtility.hoursToMillis;

  final int minutes = (int) (millis / DateUtility.minutesToMillis);
  millis      = millis % DateUtility.minutesToMillis;

  final int seconds = (int) (millis / DateUtility.secondsToMillis);
  millis      = millis % DateUtility.secondsToMillis;

  return String.format("%c%03d %02d:%02d:%02d.%03d", neg ? '-':'+', days, hours, minutes, seconds, millis);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:28,代码来源:DremioStringUtils.java

示例3: writeInterval

import org.joda.time.Period; //导入方法依赖的package包/类
@Override
public void writeInterval(boolean isNull) throws IOException {
  IntervalWriter intervalWriter = writer.interval();
  if(!isNull){
    final Period p = ISOPeriodFormat.standard().parsePeriod(parser.getValueAsString());
    int months = DateUtility.monthsFromPeriod(p);
    int days = p.getDays();
    int millis = DateUtility.millisFromPeriod(p);
    intervalWriter.writeInterval(months, days, millis);
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:12,代码来源:VectorOutput.java

示例4: parseDate

import org.joda.time.Period; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static String parseDate(final Context context, final Date date) {
    final Context ctx = context.getApplicationContext();

    final Resources res = ctx.getResources();

    final Locale locale;

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
        locale = res.getConfiguration().getLocales().get(0);
    } else {
        locale = res.getConfiguration().locale;
    }

    final DateTime dt = new DateTime(date);

    final Period period = new Period(dt.getMillis(), System.currentTimeMillis());

    final int[] periodFields = {
            period.getYears(), period.getMonths(), period.getWeeks(),
            period.getDays(), period.getHours(), period.getMinutes()
    };

    final String[] dateSpecifierSingular = res.getStringArray(R.array.date_elements_singular);
    final String[] dateSpecifierPlural = res.getStringArray(R.array.date_elements_plural);

    int i = 0;

    for (final int periodField : periodFields) {
        if (periodField > 0) {
            final String dateSpecifier;

            if (periodField > 1) {
                dateSpecifier = dateSpecifierPlural[i];
            } else {
                dateSpecifier = dateSpecifierSingular[i];
            }

            if (locale.equals(Locale.GERMANY)) {
                return String.format("%s %s %s",
                        ctx.getString(R.string.ago),
                        periodField, dateSpecifier);
            }

            return String.format("%s %s %s", periodField, dateSpecifier,
                    ctx.getString(R.string.ago));
        }

        i++;
    }

    return dateSpecifierSingular[i];
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:54,代码来源:DateUtils.java


注:本文中的org.joda.time.Period.getDays方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。