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


Java DateTimeConstants.MILLIS_PER_SECOND属性代码示例

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


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

示例1: millisPerUnit

private static int millisPerUnit(String unit) {
  switch (Ascii.toLowerCase(unit)) {
    case "d":
      return DateTimeConstants.MILLIS_PER_DAY;
    case "h":
      return DateTimeConstants.MILLIS_PER_HOUR;
    case "m":
      return DateTimeConstants.MILLIS_PER_MINUTE;
    case "s":
      return DateTimeConstants.MILLIS_PER_SECOND;
    case "ms":
      return 1;
    default:
      throw new IllegalArgumentException("Unknown duration unit " + unit);
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:pubsub,代码行数:16,代码来源:Driver.java

示例2: getDateTimeMillis

public long getDateTimeMillis(
        int year, int monthOfYear, int dayOfMonth,
        int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond)
        throws IllegalArgumentException {
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getDateTimeMillis(year, monthOfYear, dayOfMonth,
                                      hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);
    }

    FieldUtils.verifyValueBounds(DateTimeFieldType.hourOfDay(), hourOfDay, 0, 23);
    FieldUtils.verifyValueBounds(DateTimeFieldType.minuteOfHour(), minuteOfHour, 0, 59);
    FieldUtils.verifyValueBounds(DateTimeFieldType.secondOfMinute(), secondOfMinute, 0, 59);
    FieldUtils.verifyValueBounds(DateTimeFieldType.millisOfSecond(), millisOfSecond, 0, 999);

    return getDateMidnightMillis(year, monthOfYear, dayOfMonth)
        + hourOfDay * DateTimeConstants.MILLIS_PER_HOUR
        + minuteOfHour * DateTimeConstants.MILLIS_PER_MINUTE
        + secondOfMinute * DateTimeConstants.MILLIS_PER_SECOND
        + millisOfSecond;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:21,代码来源:BasicChronology.java

示例3: calculatePrintedLength

public int calculatePrintedLength(ReadablePeriod period, Locale locale) {
    long valueLong = getFieldValue(period);
    if (valueLong == Long.MAX_VALUE) {
        return 0;
    }

    int sum = Math.max(FormatUtils.calculateDigitCount(valueLong), iMinPrintedDigits);
    if (iFieldType >= SECONDS_MILLIS) {
        // valueLong contains the seconds and millis fields
        // the minimum output is 0.000, which is 4 digits
        sum = Math.max(sum, 4);
        // plus one for the decimal point
        sum++;
        if (iFieldType == SECONDS_OPTIONAL_MILLIS &&
                (Math.abs(valueLong) % DateTimeConstants.MILLIS_PER_SECOND) == 0) {
            sum -= 4; // remove three digits and decimal point
        }
        // reset valueLong to refer to the seconds part for the prefic/suffix calculation
        valueLong = valueLong / DateTimeConstants.MILLIS_PER_SECOND;
    }
    int value = (int) valueLong;

    if (iPrefix != null) {
        sum += iPrefix.calculatePrintedLength(value);
    }
    if (iSuffix != null) {
        sum += iSuffix.calculatePrintedLength(value);
    }

    return sum;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:31,代码来源:PeriodFormatterBuilder.java

示例4: printTo

public void printTo(StringBuffer buf, ReadablePeriod period, Locale locale) {
    long valueLong = getFieldValue(period);
    if (valueLong == Long.MAX_VALUE) {
        return;
    }
    int value = (int) valueLong;
    if (iFieldType >= SECONDS_MILLIS) {
        value = (int) (valueLong / DateTimeConstants.MILLIS_PER_SECOND);
    }

    if (iPrefix != null) {
        iPrefix.printTo(buf, value);
    }
    int minDigits = iMinPrintedDigits;
    if (minDigits <= 1) {
        FormatUtils.appendUnpaddedInteger(buf, value);
    } else {
        FormatUtils.appendPaddedInteger(buf, value, minDigits);
    }
    if (iFieldType >= SECONDS_MILLIS) {
        int dp = (int) (Math.abs(valueLong) % DateTimeConstants.MILLIS_PER_SECOND);
        if (iFieldType == SECONDS_MILLIS || dp > 0) {
            buf.append('.');
            FormatUtils.appendPaddedInteger(buf, dp, 3);
        }
    }
    if (iSuffix != null) {
        iSuffix.printTo(buf, value);
    }
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:30,代码来源:PeriodFormatterBuilder.java

示例5: getNewsFeed

private Future<List<Message>> getNewsFeed(User user, DateTime lastMessageDateTime, boolean background) {
    if (!isServiceEnabled(user)) {
        return SocialUtils.emptyFutureList();
    }

    FacebookClient client = null;
    if (background) {
        client = helper.getBackgroundFacebookClient(user);
    } else {
        client = helper.getFacebookClient(user);
    }
    try {
        String untilClause = "";
        if (lastMessageDateTime != null) {
            untilClause = " AND created_time < "
                    + (lastMessageDateTime.getMillis() / DateTimeConstants.MILLIS_PER_SECOND - 1);
        }

        List<StreamPost> feed = client.executeFqlQuery(NEWS_FEED_QUERY + untilClause + " LIMIT " + messagesPerFetch, StreamPost.class);

        List<Message> messages = helper.streamPostsToMessages(feed,
                user.getFacebookSettings().isFetchImages(),
                user.getFacebookSettings().getUserId(), client);

        return SocialUtils.wrapMessageList(messages);
    } catch (FacebookException ex) {
        handleException("Problem with getting news feed from facebook", ex, user);
        return SocialUtils.emptyFutureList();
    }
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:30,代码来源:FacebookService.java

示例6: durationAsString

public static String durationAsString(double duration) {
    long d = Double.valueOf(duration * DateTimeConstants.MILLIS_PER_SECOND).longValue();
    long days = d / (DateTimeConstants.SECONDS_PER_DAY * DateTimeConstants.MILLIS_PER_SECOND);
    long secs = d % (DateTimeConstants.SECONDS_PER_DAY * DateTimeConstants.MILLIS_PER_SECOND);
    Period p = new Period(secs);
    return "" + days + " d " + periodFormatter.print(p);
}
 
开发者ID:momega,项目名称:spacesimulator2,代码行数:7,代码来源:TimeUtils.java

示例7: getTimeout

private long getTimeout(RemoteCommand command) {
  if (command.getTimeout() == null) {
    return DEFAULT_TIMEOUT_SEC * DateTimeConstants.MILLIS_PER_SECOND;
  }
  return command.getTimeout().getMillis();
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:6,代码来源:RemoteCommandExecutor.java

示例8: printTo

public void printTo(
        StringBuffer buf, long instant, Chronology chrono,
        int displayOffset, DateTimeZone displayZone, Locale locale) {
    if (displayZone == null) {
        return;  // no zone
    }
    if (displayOffset == 0 && iZeroOffsetPrintText != null) {
        buf.append(iZeroOffsetPrintText);
        return;
    }
    if (displayOffset >= 0) {
        buf.append('+');
    } else {
        buf.append('-');
        displayOffset = -displayOffset;
    }

    int hours = displayOffset / DateTimeConstants.MILLIS_PER_HOUR;
    FormatUtils.appendPaddedInteger(buf, hours, 2);
    if (iMaxFields == 1) {
        return;
    }
    displayOffset -= hours * (int)DateTimeConstants.MILLIS_PER_HOUR;
    if (displayOffset == 0 && iMinFields <= 1) {
        return;
    }

    int minutes = displayOffset / DateTimeConstants.MILLIS_PER_MINUTE;
    if (iShowSeparators) {
        buf.append(':');
    }
    FormatUtils.appendPaddedInteger(buf, minutes, 2);
    if (iMaxFields == 2) {
        return;
    }
    displayOffset -= minutes * DateTimeConstants.MILLIS_PER_MINUTE;
    if (displayOffset == 0 && iMinFields <= 2) {
        return;
    }

    int seconds = displayOffset / DateTimeConstants.MILLIS_PER_SECOND;
    if (iShowSeparators) {
        buf.append(':');
    }
    FormatUtils.appendPaddedInteger(buf, seconds, 2);
    if (iMaxFields == 3) {
        return;
    }
    displayOffset -= seconds * DateTimeConstants.MILLIS_PER_SECOND;
    if (displayOffset == 0 && iMinFields <= 3) {
        return;
    }

    if (iShowSeparators) {
        buf.append('.');
    }
    FormatUtils.appendPaddedInteger(buf, displayOffset, 3);
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:58,代码来源:DateTimeFormatterBuilder.java

示例9: getClaimAsDate

private Date getClaimAsDate(String key) {
    if (getClaim(key) == null) {
        return null;
    }
    return new Date((Long) getClaim(key) * DateTimeConstants.MILLIS_PER_SECOND);
}
 
开发者ID:wdawson,项目名称:dropwizard-auth-example,代码行数:6,代码来源:JwtClaims.java

示例10: init

@PostConstruct
public void init() {
    map = new ExpiringMap<String, ActivitySession>(30 * DateTimeConstants.MILLIS_PER_SECOND, activitySessionExpirationListener);
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:4,代码来源:UserActivityController.java


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