Skip to content

Conversion

Purpose

A general purpose conversion utilities.

Methods

Binding name: p6.conversion


Method: byte[] getBytesFromUUID(UUID uuid)

Convert an UUID to a byte array.

Parameters:

  • uuid: the UUID to be converted

Method: UUID getUUIDFromBytes(byte[] bytes)

Convert a byte array to an UUID.

Parameters:

  • bytes: the byte representation of an UUID

Method: ZonedDateTime bigIntegerToZDT(BigInteger epoch)

Convert an epoch (in millisec) to a date time.

Parameters:

  • epoch: the epoch (in millisec)

Method: BigInteger zdtToBigInteger(ZonedDateTime zdt)

Convert a date time to epoch (in millisec).

Parameters:

  • zdt: the date time

Examples

Example 1

`Convert a random UUID into a byte array

def uuid = UUID.randomUUID()
def bytes = p6.conversion.getBytesFromUUID(uuid)

Example 2

Convert a byte array to a UUID

def uuid = p6.conversion.getUUIDFromBytes(bytes)

Example 3

Convert an epoch to a ZonedDateTime

def epoch = 1550160528000
def zdt = p6.conversion.bigIntegerToZDT(epoch)

Example 4

Convert a ZoneDateTime to an epoch

def epoch = p6.conversion.zdtToBigInteger(zdt)