本文整理汇总了Java中com.fasterxml.uuid.EthernetAddress.toByteArray方法的典型用法代码示例。如果您正苦于以下问题:Java EthernetAddress.toByteArray方法的具体用法?Java EthernetAddress.toByteArray怎么用?Java EthernetAddress.toByteArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.uuid.EthernetAddress
的用法示例。
在下文中一共展示了EthernetAddress.toByteArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newTimeUUID
import com.fasterxml.uuid.EthernetAddress; //导入方法依赖的package包/类
/**
* Generate a timeuuid with the given timestamp in milliseconds and the time offset. Useful when you need to
* generate sequential UUIDs for the same period in time. I.E
* <p/>
* newTimeUUID(1000, 0) <br/> newTimeUUID(1000, 1) <br /> newTimeUUID(1000, 2) <br />
* <p/>
* etc.
* <p/>
* Only use this method if you are absolutely sure you need it. When it doubt use the method without the timestamp
* offset
*
* @param ts The timestamp in milliseconds
* @param timeoffset The offset, which should always be <= 10000. If you go beyond this range, the millisecond will
* be incremented since this is beyond the possible values when coverrting from millis to 1/10 microseconds stored
* in the time uuid.
*/
public static UUID newTimeUUID( long ts, int timeoffset ) {
if ( ts == 0 ) {
return newTimeUUID();
}
byte[] uuidBytes = new byte[16];
// 47 bits of randomness
EthernetAddress eth = EthernetAddress.constructMulticastAddress();
eth.toByteArray( uuidBytes, 10 );
setTimestamp( ts, uuidBytes, getRandomClockSequence(), timeoffset );
return uuid( uuidBytes );
}