Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next version #105

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ All notable changes to this project will be documented in this file.

Nothing unreleased.

## [6.1.0] - 2025-xx-xx

- Added microsecond precision to UUIDv7 when available;
- Added methods to `GUID`;
- Refactored many classes;
- Updated som tests.

## [6.0.0] - 2024-07-07

This version has breaking changes.
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ Maven:
<dependency>
<groupId>com.github.f4b6a3</groupId>
<artifactId>uuid-creator</artifactId>
<version>6.0.0</version>
<version>6.1.0</version>
</dependency>
```

Gradle:

```
implementation 'com.github.f4b6a3:uuid-creator:6.0.0'
implementation 'com.github.f4b6a3:uuid-creator:6.1.0'
```

See more options in [maven.org](https://search.maven.org/artifact/com.github.f4b6a3/uuid-creator).
Expand Down Expand Up @@ -147,14 +147,21 @@ GUID guid = GUID.v6();
GUID guid = GUID.v7();
```

You can generate JDK's UUIDs using GUID's API. For example, you can generate a JDK's UUID version 7 with this simple statement:
You can generate random-based GUIDs by passing an instance of `SecureRandom` as a parameter:

```java
GUID guid = GUID.v4(new SecureRandom());
```

You can also generate JDK's UUIDs using GUID's API. For example, you can generate a JDK's UUID version 7 with this simple statement:

```java
UUID uuid = GUID.v7().toUUID();
```

> **NOTE:**
> It uses a **non-cryptographic** PRNG. So it doesn't block when generating random-based UUIDs. However, it is not recommended when the security provided by “cryptographic quality” generators is considered necessary.
> It uses by default a **non-cryptographic** PRNG. So it doesn't block when generating random-based UUIDs. However, it is not recommended when the security provided by “cryptographic quality” generators is considered necessary. In this case, you can pass a `SecureRandom` instance as a parameter to any method that expects it.


Other identifier generators
------------------------------------------------------
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/github/f4b6a3/uuid/UuidCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,16 @@ public static UUID getTimeOrderedEpochPlusN() {
* is the timestamp in hexadecimal.
* <p>
* The random bits are generated with each method invocation.
* <p>
* You can use this method to produce UUIDs with any instant you want, for
* example to obfuscate the actual generation instant in a simple way. Example:
* <p>
*
* <pre>{@code
* // Shift the generation instant 1 day ahead of system clock
* Instant instant = Instant.now().plus(Duration.ofDays(1));
* UUID uuid = UuidCreator.getTimeOrderedEpoch(instant);
* }</pre>
*
* @param instant a given instant
* @return a UUIDv7
Expand Down
Loading
Loading