本文整理汇总了Java中org.joda.time.DateTimeConstants.MILLIS_PER_HOUR属性的典型用法代码示例。如果您正苦于以下问题:Java DateTimeConstants.MILLIS_PER_HOUR属性的具体用法?Java DateTimeConstants.MILLIS_PER_HOUR怎么用?Java DateTimeConstants.MILLIS_PER_HOUR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.joda.time.DateTimeConstants
的用法示例。
在下文中一共展示了DateTimeConstants.MILLIS_PER_HOUR属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetMillisKeepLocal
public void testGetMillisKeepLocal() {
long millisLondon = TEST_TIME_SUMMER;
long millisParis = TEST_TIME_SUMMER - 1L * DateTimeConstants.MILLIS_PER_HOUR;
assertEquals(millisLondon, LONDON.getMillisKeepLocal(LONDON, millisLondon));
assertEquals(millisParis, LONDON.getMillisKeepLocal(LONDON, millisParis));
assertEquals(millisLondon, PARIS.getMillisKeepLocal(PARIS, millisLondon));
assertEquals(millisParis, PARIS.getMillisKeepLocal(PARIS, millisParis));
assertEquals(millisParis, LONDON.getMillisKeepLocal(PARIS, millisLondon));
assertEquals(millisLondon, PARIS.getMillisKeepLocal(LONDON, millisParis));
DateTimeZone zone = DateTimeZone.getDefault();
try {
DateTimeZone.setDefault(LONDON);
assertEquals(millisLondon, PARIS.getMillisKeepLocal(null, millisParis));
} finally {
DateTimeZone.setDefault(zone);
}
}
示例2: 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);
}
}
示例3: 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;
}
示例4: importMessages
@Scheduled(fixedRate=2 * DateTimeConstants.MILLIS_PER_HOUR)
public void importMessages() {
userDao.performBatched(User.class, 100, new Dao.PageableOperation<User>() {
@Override
public void execute() {
for (User user : getData()) {
for (SocialNetworkService sns : socialNetworks) {
try {
sns.importMessages(user); // the method itself verifies whether the user has configured import
} catch (Exception ex) {
logger.error("Problem importing messages for user " + user, ex);
}
}
}
}
});
}
示例5: fillInMemoryQueue
@Scheduled(fixedRate=DateTimeConstants.MILLIS_PER_HOUR)
public void fillInMemoryQueue() {
DateTime inOneHour = new DateTime().plusHours(1);
List<ScheduledMessage> messages = messageDao.getScheduledMessages(inOneHour);
for (ScheduledMessage msg : messages) {
// push to the queue only if it is scheduled to be sent more than 65 minutes from the moment of scheduling
// otherwise it would be in the queue already (see ShareService#schedule)
if (msg.getTimeOfScheduling().plusMinutes(65).isBefore(msg.getScheduledTime())) {
queue.offer(msg);
}
}
}
示例6: display
@CliCommand(value = DISPLAY_AGGR_COUNTER, help = "Display aggregate counter values by chosen interval and "
+ "resolution(minute, hour)")
public Table display(
@CliOption(optionContext = "existing-aggregate-counter disable-string-converter", key = { "",
"name" }, help = "the name of the aggregate counter to display", mandatory = true) String name,
@CliOption(key = "from", help = "start-time for the interval. format: 'yyyy-MM-dd HH:mm:ss'", mandatory = false) String from,
@CliOption(key = "to", help = "end-time for the interval. format: 'yyyy-MM-dd HH:mm:ss'. defaults to "
+ "now", mandatory = false) String to,
@CliOption(key = "lastHours", help = "set the interval to last 'n' hours", mandatory = false) Integer lastHours,
@CliOption(key = "lastDays", help = "set the interval to last 'n' days", mandatory = false) Integer lastDays,
@CliOption(key = "resolution", help = "the size of the bucket to aggregate (minute, hour, day, month)", mandatory = false, unspecifiedDefaultValue = "hour") AggregateCounterOperations.Resolution resolution,
@CliOption(key = "pattern", help = "the pattern used to format the count values (see DecimalFormat)", mandatory = false, unspecifiedDefaultValue = NumberFormatConverter.DEFAULT) NumberFormat pattern) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date fromDate;
switch (Assertions.atMostOneOf("from", from, "lastHours", lastHours, "lastDays", lastDays)) {
case 0:
fromDate = dateFormat.parse(from);
break;
case 1:
fromDate = new Date(
System.currentTimeMillis() - ((long) lastHours) * DateTimeConstants.MILLIS_PER_HOUR);
break;
case 2:
fromDate = new Date(System.currentTimeMillis() - ((long) lastDays) * DateTimeConstants.MILLIS_PER_DAY);
break;
default:
fromDate = null;
break;
}
Date toDate = (to == null) ? null : dateFormat.parse(to);
AggregateCounterResource aggResource = aggregateCounterOperations().retrieve(name, fromDate, toDate,
resolution);
return displayAggrCounter(aggResource, pattern);
}
catch (ParseException pe) {
throw new IllegalArgumentException(
"Parse exception ocurred while parsing the 'from/to' options. The accepted date format is "
+ dateFormat.toPattern());
}
}
示例7: 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);
}
示例8: useTimeArithmetic
static boolean useTimeArithmetic(DurationField field) {
// Use time of day arithmetic rules for unit durations less than
// typical time zone offsets.
return field != null && field.getUnitMillis() < DateTimeConstants.MILLIS_PER_HOUR * 12;
}