---
# System prepended metadata

title: generate uuid
tags: [實作相關]

---

generate uuid
===

```java=
public String createTransactionID() throws Exception{
    String uuid = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase();
    return uuid.replaceAll("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5");
}

```

## Ref.
[Generating unique id in android (UUID)](https://stackoverflow.com/a/40237325)

###### tags: `實作相關`