0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ApexでIPv4アドレスを整形

Posted at
  // IPv4アドレスを整形 (111.11.01.001 → 111.11.1.1)
  public static String formatIPv4Address(String ipAddress) {
    String[] octets = ipAddress.split('\\.');
    if (octets.size() != 4) {
      return null;
    }
    String formattedIpAddress = '';
    for (Integer i = 0; i < 4; i++) {
      if (i != 0) {
        formattedIpAddress += '.';
      }
      formattedIpAddress += Integer.valueOf(octets[i]).toString();
    }
    return formattedIpAddress;
  }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?