Java tutorial
//package com.java2s; import java.util.Locale; public class Main { private static void test_getRawMacAddress() { String macAddressForMesh = "1A3456389034"; String result = getRawMacAddress(macAddressForMesh); if (result.equals("1a:34:56:38:90:34")) { System.out.println("test_getRawMacAddress() pass"); } else { System.out.println("test_getRawMacAddress() fail"); } } /** * Get the raw mac address from macAddress for Mesh. It is an inverse method for getMacAddressForMesh. * * @param macAddressForMesh the macAddress for Mesh * @return the raw mac address */ public static String getRawMacAddress(String macAddressForMesh) { StringBuilder sb = new StringBuilder(); char c; for (int i = 0; i < macAddressForMesh.length(); i++) { c = macAddressForMesh.charAt(i); sb.append(c); if (i % 2 != 0 && i != macAddressForMesh.length() - 1) { sb.append(':'); } } return sb.toString().toLowerCase(Locale.US); } }