Class DateOfBirth


  • public class DateOfBirth
    extends Object
    A representation of a date of birth according to the schema (where "YYYY-MM-DD", "YYYY-MM", "YYYY" and "") is allowed.
    Author:
    Martin Lindström (martin@idsec.se), Henrik Bengtsson (extern.henrik.bengtsson@digg.se), Henric Norlander (extern.henric.norlander@digg.se)
    • Constructor Detail

      • DateOfBirth

        public DateOfBirth​(String dob)
                    throws DateTimeException
        Constructor taking a string representation of a date of birth.
        Parameters:
        dob - the string representation of the date of birth
        Throws:
        DateTimeException - for parse errors
      • DateOfBirth

        public DateOfBirth​(LocalDate dob)
        Constructor taking a LocalDate.
        Parameters:
        dob - the date of birth
    • Method Detail

      • isCompleteDate

        public boolean isCompleteDate()
        A predicate that tells whether this date is "complete", meaning YYYY-MM-DD.
        Returns:
        true if this is a complete date and false otherwise
      • asLocalDate

        public LocalDate asLocalDate()
        Gets the date of birth as a LocalDate object.
        Returns:
        a LocalDate object or null if this object doesn't represent a complete date
      • getYear

        public Year getYear()
        Gets the year.
        Returns:
        the year, or null if this is not available
      • getMonth

        public Month getMonth()
        Gets the month (if available).
        Returns:
        the month, or null if this is not available
      • getDayOfMonth

        public Integer getDayOfMonth()
        Gets the day of month (if available).
        Returns:
        the day of month, or null if this is not available
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • toString

        public String toString()
        Returns the date representation (YYYY-MM-DD, YYYY-MM, YYYY or unknown).
        Overrides:
        toString in class Object