Oracle
 sql >> Datenbank >  >> RDS >> Oracle

Java-Guid-Konvertierung in Oracle Raw(16)-String

Diese folgende Codebasis funktioniert:

private byte[] convertToOracleRaw(UUID uuid) {
    String uuidString = uuid.toString().replace("-", "").toUpperCase();
    String finalValue = "";
    finalValue += uuidString.substring(6,8);
    finalValue += uuidString.substring(4,6);
    finalValue += uuidString.substring(2,4);
    finalValue += uuidString.substring(0,2);
    finalValue += uuidString.substring(10,12);
    finalValue += uuidString.substring(8,10);
    finalValue += uuidString.substring(14,16);
    finalValue += uuidString.substring(12,14);
    finalValue += uuidString.substring(16,18);

    finalValue += uuidString.substring(18, uuidString.length());  // final string
    return DatatypeConverter.parseHexBinary(finalValue);  // in hex binary
}