本文整理汇总了Java中com.illposed.osc.OSCBundle.TIMESTAMP_IMMEDIATE属性的典型用法代码示例。如果您正苦于以下问题:Java OSCBundle.TIMESTAMP_IMMEDIATE属性的具体用法?Java OSCBundle.TIMESTAMP_IMMEDIATE怎么用?Java OSCBundle.TIMESTAMP_IMMEDIATE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.illposed.osc.OSCBundle
的用法示例。
在下文中一共展示了OSCBundle.TIMESTAMP_IMMEDIATE属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readTimeTag
/**
* Reads the time tag and convert it to a Java Date object.
* A timestamp is a 64 bit number representing the time in NTP format.
* The first 32 bits are seconds since 1900, the second 32 bits are
* fractions of a second.
* @return a {@link Date}
*/
private Date readTimeTag() {
byte[] secondBytes = new byte[8];
byte[] fractionBytes = new byte[8];
for (int i = 0; i < 4; i++) {
// clear the higher order 4 bytes
secondBytes[i] = 0; fractionBytes[i] = 0;
}
// while reading in the seconds & fraction, check if
// this timetag has immediate semantics
boolean isImmediate = true;
for (int i = 4; i < 8; i++) {
secondBytes[i] = bytes[streamPosition++];
if (secondBytes[i] > 0) {
isImmediate = false;
}
}
for (int i = 4; i < 8; i++) {
fractionBytes[i] = bytes[streamPosition++];
if (i < 7) {
if (fractionBytes[i] > 0) {
isImmediate = false;
}
} else {
if (fractionBytes[i] > 1) {
isImmediate = false;
}
}
}
if (isImmediate) {
return OSCBundle.TIMESTAMP_IMMEDIATE;
}
BigInteger secsSince1900 = new BigInteger(secondBytes);
long secsSince1970 = secsSince1900.longValue()
- OSCBundle.SECONDS_FROM_1900_TO_1970.longValue();
// no point maintaining times in the distant past
if (secsSince1970 < 0) {
secsSince1970 = 0;
}
long fraction = (new BigInteger(fractionBytes).longValue());
// this line was cribbed from jakarta commons-net's NTP TimeStamp code
fraction = (fraction * 1000) / 0x100000000L;
// I do not know where, but I'm losing 1ms somewhere...
fraction = (fraction > 0) ? fraction + 1 : 0;
long millisecs = (secsSince1970 * 1000) + fraction;
return new Date(millisecs);
}
示例2: readTimeTag
/**
* Reads the time tag and convert it to a Java Date object.
* A timestamp is a 64 bit number representing the time in NTP format.
* The first 32 bits are seconds since 1900, the second 32 bits are
* fractions of a second.
* @return a {@link Date}
*/
private Date readTimeTag() {
byte[] secondBytes = new byte[8];
byte[] fractionBytes = new byte[8];
for (int i = 0; i < 4; i++) {
// clear the higher order 4 bytes
secondBytes[i] = 0;
fractionBytes[i] = 0;
}
// while reading in the seconds & fraction, check if
// this timetag has immediate semantics
boolean isImmediate = true;
for (int i = 4; i < 8; i++) {
secondBytes[i] = bytes[streamPosition++];
if (secondBytes[i] > 0) {
isImmediate = false;
}
}
for (int i = 4; i < 8; i++) {
fractionBytes[i] = bytes[streamPosition++];
if (i < 7) {
if (fractionBytes[i] > 0) {
isImmediate = false;
}
} else {
if (fractionBytes[i] > 1) {
isImmediate = false;
}
}
}
if (isImmediate) {
return OSCBundle.TIMESTAMP_IMMEDIATE;
}
final long secsSince1900 = new BigInteger(secondBytes).longValue();
long secsSince1970 = secsSince1900 - OSCBundle.SECONDS_FROM_1900_TO_1970;
// no point maintaining times in the distant past
if (secsSince1970 < 0) {
secsSince1970 = 0;
}
long fraction = (new BigInteger(fractionBytes).longValue());
// this line was cribbed from jakarta commons-net's NTP TimeStamp code
fraction = (fraction * 1000) / 0x100000000L;
// I do not know where, but I'm losing 1ms somewhere...
fraction = (fraction > 0) ? fraction + 1 : 0;
long millisecs = (secsSince1970 * 1000) + fraction;
return new Date(millisecs);
}