Skip to content

Instantly share code, notes, and snippets.

@soverby
Created March 13, 2019 11:52
Show Gist options
  • Save soverby/cdb0116189d0c9879886d4b978bb0df9 to your computer and use it in GitHub Desktop.
Save soverby/cdb0116189d0c9879886d4b978bb0df9 to your computer and use it in GitHub Desktop.
Java UUID fromString Behavior
package com.accolade.test;
import java.util.UUID;
public class TestUUID {
public static void main(String[] args) {
// Valid UUID
UUID uuid1 = UUID.fromString("123e4567-e89b-12d3-a456-426655440000");
// Not a valid UUID, UUID will left pad zeros
UUID uuid2 = UUID.fromString("e4567-89b-d3-6-555");
// Not a valid UUID, UUID truncates to make it fit...
UUID uuid3 = UUID.fromString("5555123e4567-5555e89b-55512d3-555a456-5555426655440000");
System.out.println(uuid1);
System.out.println(uuid2);
System.out.println(uuid3);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment