code: public static String wellFormedMac(String mac) {
          int HEX_RADIX = 16;
          int[] bytes = new int[6];
          String[] splitAtColon = mac.split(":");
          if (splitAtColon.length == 6) {
              for (int i = 0; i < 6; ++i) {
                  bytes[i] = Integer.parseInt(splitAtColon[i], HEX_RADIX);
              }
          } else {
              String[] splitAtLine = mac.split("-");
              if (splitAtLine.length == 6) {
                  for (int i = 0; i < 6; ++i) {
                      bytes[i] = Integer.parseInt(splitAtLine[i], HEX_RADIX);
                  }
              } else if (mac.length() == 12) {
                  for (int i = 0; i < 6; ++i) {
                      bytes[i] = Integer.parseInt(mac.substring(i * 2, (i + 1) * 2), HEX_RADIX);
                  }
              } else if (mac.length() == 17) {
                  for (int i = 0; i < 6; ++i) {
                      bytes[i] = Integer.parseInt(mac.substring(i * 3, (i * 3) + 2), HEX_RADIX);
                  }
              } else {
                  throw new IllegalArgumentException("Can't read this string as mac address");
  
              }
          }
          StringBuilder sb = new StringBuilder();
          for (int i = 0; i < 6; ++i) {
              String hex = Integer.toHexString(bytes[i]);
              if (hex.length() == 1) {
                  hex = "0" + hex;
              }
              if (sb.length() != 0)
                  sb.append(":");
              sb.append(hex);
          }
          return sb.toString();
      }
docs: Bring a mac address to the form 01:23:45:AB:CD:EF
  
  @param mac address to be well-formed
  @return well-formed mac address