Package org.xbill.DNS

Class TTL

java.lang.Object
org.xbill.DNS.TTL

public final class TTL extends Object
Routines for parsing BIND-style TTL values. These values consist of numbers followed by 1 letter units of time (W - week, D - day, H - hour, M - minute, S - second).
Author:
Brian Wellington
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    format(long ttl)
     
    static long
    parse(String s, boolean clamp)
    Parses a TTL-like value, which can either be expressed as a number or a BIND-style string with numbers and units.
    static long
    Parses a TTL, which can either be expressed as a number or a BIND-style string with numbers and units.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • parse

      public static long parse(String s, boolean clamp)
      Parses a TTL-like value, which can either be expressed as a number or a BIND-style string with numbers and units.
      Parameters:
      s - The string representing the numeric value.
      clamp - Whether to clamp values in the range [MAX_VALUE + 1, 2^32 -1] to MAX_VALUE. This should be donw for TTLs, but not other values which can be expressed in this format.
      Returns:
      The value as a number of seconds
      Throws:
      NumberFormatException - The string was not in a valid TTL format.
    • parseTTL

      public static long parseTTL(String s)
      Parses a TTL, which can either be expressed as a number or a BIND-style string with numbers and units.
      Parameters:
      s - The string representing the TTL
      Returns:
      The TTL as a number of seconds
      Throws:
      NumberFormatException - The string was not in a valid TTL format.
    • format

      public static String format(long ttl)