Conversion

Purpose

A general purpose conversion utilities.

Methods

Binding name: 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 = conversion.getBytesFromUUID(uuid)

Example 2

Convert a byte array to a UUID

def uuid = conversion.getUUIDFromBytes(bytes)

Example 3

Convert an epoch to a ZonedDateTime

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

Example 4

Convert a ZoneDateTime to an epoch

def epoch = conversion.zdtToBigInteger(zdt)