Java tutorial
//package com.java2s; //License from project: Apache License import android.os.ParcelUuid; import android.support.annotation.NonNull; import java.util.UUID; public class Main { /** * Obtains a ParcelUuid from Short style value. * * @param uuidShortValue the Short style UUID value. * @return an UUID instance. */ @NonNull public static ParcelUuid parcelFromShortValue(final int uuidShortValue) { return ParcelUuid.fromString( "0000" + String.format("%04X", uuidShortValue & 0xffff) + "-0000-1000-8000-00805F9B34FB"); } /** * Parses a UUID string with the format defined by toString(). * * @param uuidString the UUID string to parse. * @return an UUID instance. * @throws java.lang.NullPointerException if uuid is null. * @throws java.lang.IllegalArgumentException if uuid is not formatted correctly. */ @NonNull public static UUID fromString(@NonNull final String uuidString) { try { return UUID.fromString(uuidString); } catch (IllegalArgumentException e) { // may be a short style return UUID.fromString("0000" + uuidString + "-0000-1000-8000-00805F9B34FB"); } } }