org.gedcomx.date
Class GedcomxDateUtil

java.lang.Object
  extended by org.gedcomx.date.GedcomxDateUtil

public class GedcomxDateUtil
extends Object

Static utility functions for handling GedcomX Dates

Author:
John Clark.

Nested Class Summary
protected static class GedcomxDateUtil.Date
          A simplified representation of a date.
 
Constructor Summary
GedcomxDateUtil()
           
 
Method Summary
static GedcomxDateSimple addDuration(GedcomxDateSimple startDate, GedcomxDateDuration duration)
          Add a duration to a simple date
static int daysInMonth(Integer month, Integer year)
          Find the number of days in a month within a given year
static GedcomxDateDuration getDuration(GedcomxDateSimple startDate, GedcomxDateSimple endDate)
          Calculates the Duration between two dates
static GedcomxDateDuration multiplyDuration(GedcomxDateDuration duration, int multiplier)
          Multiple a duration by a fixed number
static GedcomxDate parse(String date)
          Parse a String representation of a Formal GedcomX Date
protected static void zipDates(GedcomxDateUtil.Date start, GedcomxDateUtil.Date end)
          Ensures that both start and end have values where the other has values.
protected static void zipDuration(GedcomxDateUtil.Date date, GedcomxDateDuration duration)
          Ensures that date has its properties initialized based on what the duration has.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GedcomxDateUtil

public GedcomxDateUtil()
Method Detail

parse

public static GedcomxDate parse(String date)
Parse a String representation of a Formal GedcomX Date

Parameters:
date - The GedcomX Date
Returns:
A GedcomxDate

getDuration

public static GedcomxDateDuration getDuration(GedcomxDateSimple startDate,
                                              GedcomxDateSimple endDate)
Calculates the Duration between two dates

Parameters:
startDate - The start date
endDate - The end date
Returns:
The duration

addDuration

public static GedcomxDateSimple addDuration(GedcomxDateSimple startDate,
                                            GedcomxDateDuration duration)
Add a duration to a simple date

Parameters:
startDate - The date to start from
duration - The duration to add
Returns:
a new simple date

multiplyDuration

public static GedcomxDateDuration multiplyDuration(GedcomxDateDuration duration,
                                                   int multiplier)
Multiple a duration by a fixed number

Parameters:
duration - The duration to multiply
multiplier - The amount to multiply by
Returns:
The new, multiplied duration

daysInMonth

public static int daysInMonth(Integer month,
                              Integer year)
Find the number of days in a month within a given year

Parameters:
month - The month
year - The year
Returns:
The number of days in the month

zipDates

protected static void zipDates(GedcomxDateUtil.Date start,
                               GedcomxDateUtil.Date end)
Ensures that both start and end have values where the other has values. For example, if start has minutes but end does not, this function will initialize minutes in end.

Parameters:
start - The start date
end - The end date

zipDuration

protected static void zipDuration(GedcomxDateUtil.Date date,
                                  GedcomxDateDuration duration)
Ensures that date has its properties initialized based on what the duration has. For example, if date does not have minutes and duration does, this will initialize minutes in the date.

Parameters:
date - The start date
duration - The duration


Copyright © 2016. All rights reserved.