oracle row类型与guid之间的相互转换

/**
 * 将oracle row类型转换为36位guid
 */
public class Test {
	/**
	 * row转换为36位guid
	 * @param guid
	 * @return
	 */
	public static String rowToGuid(String guid)
	{       
	    return guid.replaceAll("(.{2})(.{2})(.{2})(.{2})(.{2})(.{2})(.{2})(.{2})(.{4})(.{12})", "$4$3$2$1-$6$5-$8$7-$9-$10");
	}

	/**
	 * guid转换为数据库row类型
	 * @param hex
	 * @return
	 */
	public static String guidToRow(String hex)
	{       
	    return hex.replaceAll("(.{2})(.{2})(.{2})(.{2})-(.{2})(.{2})-(.{2})(.{2})-(.{4})-(.{12})", "$4$3$2$1$6$5$8$7$9$10");
	}
	public static void main(String[] args) {
		
		System.out.println(Test.rowToGuid("1124D62A7D095A40AFD940F954C6BB6B").toLowerCase());
	}

}

 

你可能感兴趣的:(JAVA,java,guid,oracle,row)