Created
March 13, 2019 11:52
-
-
Save soverby/cdb0116189d0c9879886d4b978bb0df9 to your computer and use it in GitHub Desktop.
Java UUID fromString Behavior
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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