Skip to main content

APIzation: Replication Package

[Q#3388085][A#3388104] how to create GUID in java EE

https://stackoverflow.com/q/3388085

i want to know how to create GUID number in java ee , i am using jboss 4.2.3

Answer

https://stackoverflow.com/a/3388104

APIzation

import java.util.UUID;

UUID uuid = UUID.randomUUID();

String randomUUIDString = uuid.toString();
package com.stackoverflow.api;

import java.util.UUID;

public class Human3388104 {

  public static String getUUID() {
    UUID uuid = UUID.randomUUID();
    return uuid.toString();
  }
}

package com.stackoverflow.api;

import java.util.UUID;

/**
 * how to create GUID in java EE
 *
 * @author APIzator
 * @see <a href="https://stackoverflow.com/a/3388104">https://stackoverflow.com/a/3388104</a>
 */
public class APIzator3388104 {

  public static String createGuid() throws Exception {
    UUID uuid = UUID.randomUUID();
    return uuid.toString();
  }
}