Package mil.nga.geopackage.db
Class DateConverter
- java.lang.Object
-
- mil.nga.geopackage.db.DateConverter
-
public class DateConverter extends Object
Date converter between database date formats and date objects- Since:
- 1.3.0
- Author:
- osbornb
-
-
Field Summary
Fields Modifier and Type Field Description static String
DATE_FORMAT
Date formatstatic String
DATE_FORMAT2
Non standard Date formatstatic String
DATETIME_FORMAT
Date Time formatstatic String
DATETIME_FORMAT2
Date Time format w/o milliseconds for parsing string datesstatic String
DATETIME_FORMAT3
Date Time format w/o seconds for parsing string datesstatic String
FUNCTION_DATE
SQLite date functionstatic String
FUNCTION_DATETIME
SQLite datetime functionstatic String
FUNCTION_JULIANDAY
SQLite julianday functionstatic String
FUNCTION_STRFTIME
SQLite strftime functionstatic String
FUNCTION_TIME
SQLite time function
-
Constructor Summary
Constructors Constructor Description DateConverter(String... formats)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFormat(String format)
Add date formatstatic DateConverter
converter(GeoPackageDataType type)
Get a date converter for the data typestatic DateConverter
dateConverter()
Get a date converterstatic DateConverter
dateConverter(String... formats)
Get a date converter for the provided formatsstatic DateConverter
dateTimeConverter()
Get a date time converterDate
dateValue(String date)
Get the date value of the formatted string dateboolean
isExpected()
Is a parsed date value always expectedstatic boolean
isFunction(String value)
Determine if the date/time string value is a SQLite functionvoid
setExpected(boolean expected)
Set if a parsed date value is always expectedString
stringValue(Date date)
Get the formatted string date value of the date
-
-
-
Field Detail
-
DATE_FORMAT
public static final String DATE_FORMAT
Date format- See Also:
- Constant Field Values
-
DATE_FORMAT2
public static final String DATE_FORMAT2
Non standard Date format- See Also:
- Constant Field Values
-
DATETIME_FORMAT
public static final String DATETIME_FORMAT
Date Time format- See Also:
- Constant Field Values
-
DATETIME_FORMAT2
public static final String DATETIME_FORMAT2
Date Time format w/o milliseconds for parsing string dates- See Also:
- Constant Field Values
-
DATETIME_FORMAT3
public static final String DATETIME_FORMAT3
Date Time format w/o seconds for parsing string dates- See Also:
- Constant Field Values
-
FUNCTION_DATE
public static final String FUNCTION_DATE
SQLite date function- Since:
- 3.3.0
- See Also:
- Constant Field Values
-
FUNCTION_TIME
public static final String FUNCTION_TIME
SQLite time function- Since:
- 3.3.0
- See Also:
- Constant Field Values
-
FUNCTION_DATETIME
public static final String FUNCTION_DATETIME
SQLite datetime function- Since:
- 3.3.0
- See Also:
- Constant Field Values
-
FUNCTION_JULIANDAY
public static final String FUNCTION_JULIANDAY
SQLite julianday function- Since:
- 3.3.0
- See Also:
- Constant Field Values
-
FUNCTION_STRFTIME
public static final String FUNCTION_STRFTIME
SQLite strftime function- Since:
- 3.3.0
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DateConverter
public DateConverter(String... formats)
Constructor- Parameters:
formats
- date formats- Since:
- 6.2.0
-
-
Method Detail
-
converter
public static DateConverter converter(GeoPackageDataType type)
Get a date converter for the data type- Parameters:
type
- data type- Returns:
- date converter
-
dateConverter
public static DateConverter dateConverter()
Get a date converter- Returns:
- date converter
-
dateTimeConverter
public static DateConverter dateTimeConverter()
Get a date time converter- Returns:
- date converter
-
dateConverter
public static DateConverter dateConverter(String... formats)
Get a date converter for the provided formats- Parameters:
formats
- formats- Returns:
- date converter
-
addFormat
public void addFormat(String format)
Add date format- Parameters:
format
- date format- Since:
- 6.2.0
-
isExpected
public boolean isExpected()
Is a parsed date value always expected- Returns:
- true if always expected
- Since:
- 6.2.0
-
setExpected
public void setExpected(boolean expected)
Set if a parsed date value is always expected- Parameters:
expected
- true if always expected- Since:
- 6.2.0
-
stringValue
public String stringValue(Date date)
Get the formatted string date value of the date- Parameters:
date
- date- Returns:
- formatted string date
-
dateValue
public Date dateValue(String date)
Get the date value of the formatted string date- Parameters:
date
- formatted string date- Returns:
- date
-
isFunction
public static boolean isFunction(String value)
Determine if the date/time string value is a SQLite function- Parameters:
value
- date/time string value- Returns:
- true if a function, false if the value should be parsed
- Since:
- 3.3.0
-
-