下面列出了org.joda.time.DateTimeConstants#MILLIS_PER_SECOND 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
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;
}
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;
}
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;
}
public void printTo(Writer out, ReadablePeriod period, Locale locale) throws IOException {
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(out, value);
}
int minDigits = iMinPrintedDigits;
if (minDigits <= 1) {
FormatUtils.writeUnpaddedInteger(out, value);
} else {
FormatUtils.writePaddedInteger(out, value, minDigits);
}
if (iFieldType >= SECONDS_MILLIS) {
int dp = (int) (Math.abs(valueLong) % DateTimeConstants.MILLIS_PER_SECOND);
if (iFieldType == SECONDS_MILLIS || dp > 0) {
out.write('.');
FormatUtils.writePaddedInteger(out, dp, 3);
}
}
if (iSuffix != null) {
iSuffix.printTo(out, value);
}
}
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;
}
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);
}
}
public void printTo(Writer out, ReadablePeriod period, Locale locale) throws IOException {
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(out, value);
}
int minDigits = iMinPrintedDigits;
if (minDigits <= 1) {
FormatUtils.writeUnpaddedInteger(out, value);
} else {
FormatUtils.writePaddedInteger(out, value, minDigits);
}
if (iFieldType >= SECONDS_MILLIS) {
int dp = (int) (Math.abs(valueLong) % DateTimeConstants.MILLIS_PER_SECOND);
if (iFieldType == SECONDS_MILLIS || dp > 0) {
out.write('.');
FormatUtils.writePaddedInteger(out, dp, 3);
}
}
if (iSuffix != null) {
iSuffix.printTo(out, value);
}
}
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 bufLen = buf.length();
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) {
if (valueLong < 0 && valueLong > -DateTimeConstants.MILLIS_PER_SECOND) {
buf.insert(bufLen, '-');
}
buf.append('.');
FormatUtils.appendPaddedInteger(buf, dp, 3);
}
}
if (iSuffix != null) {
iSuffix.printTo(buf, value);
}
}
public void printTo(Writer out, ReadablePeriod period, Locale locale) throws IOException {
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(out, value);
}
int minDigits = iMinPrintedDigits;
if (minDigits <= 1) {
FormatUtils.writeUnpaddedInteger(out, value);
} else {
FormatUtils.writePaddedInteger(out, value, minDigits);
}
if (iFieldType >= SECONDS_MILLIS) {
int dp = (int) (Math.abs(valueLong) % DateTimeConstants.MILLIS_PER_SECOND);
if (iFieldType == SECONDS_MILLIS || dp > 0) {
out.write('.');
FormatUtils.writePaddedInteger(out, dp, 3);
}
}
if (iSuffix != null) {
iSuffix.printTo(out, value);
}
}
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 or 5 digits with a negative
sum = (valueLong < 0 ? Math.max(sum, 5) : 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;
}
public void printTo(Writer out, ReadablePeriod period, Locale locale) throws IOException {
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(out, value);
}
int minDigits = iMinPrintedDigits;
if (minDigits <= 1) {
FormatUtils.writeUnpaddedInteger(out, value);
} else {
FormatUtils.writePaddedInteger(out, value, minDigits);
}
if (iFieldType >= SECONDS_MILLIS) {
int dp = (int) (Math.abs(valueLong) % DateTimeConstants.MILLIS_PER_SECOND);
if (iFieldType == SECONDS_MILLIS || dp > 0) {
out.write('.');
FormatUtils.writePaddedInteger(out, dp, 3);
}
}
if (iSuffix != null) {
iSuffix.printTo(out, value);
}
}
public void printTo(Writer out, ReadablePeriod period, Locale locale) throws IOException {
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(out, value);
}
int minDigits = iMinPrintedDigits;
if (minDigits <= 1) {
FormatUtils.writeUnpaddedInteger(out, value);
} else {
FormatUtils.writePaddedInteger(out, value, minDigits);
}
if (iFieldType >= SECONDS_MILLIS) {
int dp = (int) (Math.abs(valueLong) % DateTimeConstants.MILLIS_PER_SECOND);
if (iFieldType == SECONDS_MILLIS || dp > 0) {
out.write('.');
FormatUtils.writePaddedInteger(out, dp, 3);
}
}
if (iSuffix != null) {
iSuffix.printTo(out, value);
}
}
public void printTo(Writer out, ReadablePeriod period, Locale locale) throws IOException {
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(out, value);
}
int minDigits = iMinPrintedDigits;
if (minDigits <= 1) {
FormatUtils.writeUnpaddedInteger(out, value);
} else {
FormatUtils.writePaddedInteger(out, value, minDigits);
}
if (iFieldType >= SECONDS_MILLIS) {
int dp = (int) (Math.abs(valueLong) % DateTimeConstants.MILLIS_PER_SECOND);
if (iFieldType == SECONDS_MILLIS || dp > 0) {
out.write('.');
FormatUtils.writePaddedInteger(out, dp, 3);
}
}
if (iSuffix != null) {
iSuffix.printTo(out, value);
}
}
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 or 5 digits with a negative
sum = (valueLong < 0 ? Math.max(sum, 5) : 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;
}
@Scheduled(fixedDelay=10 * DateTimeConstants.MILLIS_PER_SECOND)
public void run() {
try {
TimelineMusicRequest request = dao.getUnprocessedTimelineMusicRequest();
if (request == null) {
return;
}
long start = System.currentTimeMillis();
TimelineMusic music = service.storeUserTimelinePiece(request.getUser());
service.completeRequest(request, start);
sendEmail(music);
} catch (Exception ex) {
logger.error("Problem processing twitter music request", ex);
}
}
public void printTo(
Writer out, long instant, Chronology chrono,
int displayOffset, DateTimeZone displayZone, Locale locale) throws IOException {
if (displayZone == null) {
return; // no zone
}
if (displayOffset == 0 && iZeroOffsetPrintText != null) {
out.write(iZeroOffsetPrintText);
return;
}
if (displayOffset >= 0) {
out.write('+');
} else {
out.write('-');
displayOffset = -displayOffset;
}
int hours = displayOffset / DateTimeConstants.MILLIS_PER_HOUR;
FormatUtils.writePaddedInteger(out, 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) {
out.write(':');
}
FormatUtils.writePaddedInteger(out, 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) {
out.write(':');
}
FormatUtils.writePaddedInteger(out, seconds, 2);
if (iMaxFields == 3) {
return;
}
displayOffset -= seconds * DateTimeConstants.MILLIS_PER_SECOND;
if (displayOffset == 0 && iMinFields == 3) {
return;
}
if (iShowSeparators) {
out.write('.');
}
FormatUtils.writePaddedInteger(out, displayOffset, 3);
}
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);
}
public void printTo(
Writer out, long instant, Chronology chrono,
int displayOffset, DateTimeZone displayZone, Locale locale) throws IOException {
if (displayZone == null) {
return; // no zone
}
if (displayOffset == 0 && iZeroOffsetPrintText != null) {
out.write(iZeroOffsetPrintText);
return;
}
if (displayOffset >= 0) {
out.write('+');
} else {
out.write('-');
displayOffset = -displayOffset;
}
int hours = displayOffset / DateTimeConstants.MILLIS_PER_HOUR;
FormatUtils.writePaddedInteger(out, 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) {
out.write(':');
}
FormatUtils.writePaddedInteger(out, 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) {
out.write(':');
}
FormatUtils.writePaddedInteger(out, seconds, 2);
if (iMaxFields == 3) {
return;
}
displayOffset -= seconds * DateTimeConstants.MILLIS_PER_SECOND;
if (displayOffset == 0 && iMinFields == 3) {
return;
}
if (iShowSeparators) {
out.write('.');
}
FormatUtils.writePaddedInteger(out, displayOffset, 3);
}
public void printTo(
Writer out, long instant, Chronology chrono,
int displayOffset, DateTimeZone displayZone, Locale locale) throws IOException {
if (displayZone == null) {
return; // no zone
}
if (displayOffset == 0 && iZeroOffsetPrintText != null) {
out.write(iZeroOffsetPrintText);
return;
}
if (displayOffset >= 0) {
out.write('+');
} else {
out.write('-');
displayOffset = -displayOffset;
}
int hours = displayOffset / DateTimeConstants.MILLIS_PER_HOUR;
FormatUtils.writePaddedInteger(out, 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) {
out.write(':');
}
FormatUtils.writePaddedInteger(out, 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) {
out.write(':');
}
FormatUtils.writePaddedInteger(out, seconds, 2);
if (iMaxFields == 3) {
return;
}
displayOffset -= seconds * DateTimeConstants.MILLIS_PER_SECOND;
if (displayOffset == 0 && iMinFields == 3) {
return;
}
if (iShowSeparators) {
out.write('.');
}
FormatUtils.writePaddedInteger(out, displayOffset, 3);
}