Package se.digg.dgc.payload.v1
Class DateOfBirth
- java.lang.Object
-
- se.digg.dgc.payload.v1.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 Summary
Constructors Constructor Description DateOfBirth(String dob)Constructor taking a string representation of a date of birth.DateOfBirth(LocalDate dob)Constructor taking aLocalDate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LocalDateasLocalDate()Gets the date of birth as aLocalDateobject.booleanequals(Object obj)IntegergetDayOfMonth()Gets the day of month (if available).MonthgetMonth()Gets the month (if available).YeargetYear()Gets the year.inthashCode()booleanisCompleteDate()A predicate that tells whether this date is "complete", meaning YYYY-MM-DD.StringtoString()Returns the date representation (YYYY-MM-DD, YYYY-MM, YYYY or unknown).
-
-
-
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
-
-
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 aLocalDateobject.- 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
-
-