javafilenet-content-engine

How to convert hexadecimal IDs (from Oracle/DB2) to GUID (FileNet standard)?


Searching for objects directly on the database used by FileNet (Oracle or IBM DB2) provides hexadecimal IDs, like this:

F324E0C2A4AA884FACAAE6918AFFB163

How can I convert them in GUID standard, the one used by FileNet, using Java APIs? Example of result:

{C2E024F3-AAA4-4F88-ACAA-E6918AFFB163}

Solution

  • public static String hexToGUID(String hex) {
            return "{" + hex.substring(6, 8) + hex.substring(4, 6) + hex.substring(2, 4) + hex.substring(0, 2) + "-"
                    + hex.substring(10, 12) + hex.substring(8, 10) + "-" + hex.substring(14, 16) + hex.substring(12, 14)
                    + "-" + hex.substring(16, 18) + hex.substring(18, 20) + "-" + hex.substring(20, 22)
                    + hex.substring(22, 24) + hex.substring(24, 26) + hex.substring(26, 28) + hex.substring(28, 30)
                    + hex.substring(30, 32) + "}";
        }