Module org.firebirdsql.jaybird
Package org.firebirdsql.jaybird.util

# Class LegacyDatetimeConversions

java.lang.Object
org.firebirdsql.jaybird.util.LegacyDatetimeConversions

public final class LegacyDatetimeConversions extends Object
Class to hold conversions and manipulation of legacy datetime types (`Date`, `Time` and `Timestamp`).

Since:
  6
Author:
  Mark Rotteveel

## Method Summary

Modifier and Type
Method
Description
`static Date`
`toDate(LocalDate val, @Nullable Calendar c)`
Converts a local date to a date using calendar `c`.
`static LocalDate`
`toLocalDate(Date val, @Nullable Calendar c)`
Converts a date to a local date using calendar `c`.
`static LocalDateTime`
`toLocalDateTime(Timestamp val, @Nullable Calendar c)`
Converts a timestamp to a local date time using calendar `c`.
`static LocalTime`
`toLocalTime(Time val, @Nullable Calendar c)`
Converts a time to a local time using calendar `c`.
`static Time`
`toTime(LocalTime val, @Nullable Calendar c)`
Converts a local time to a time using calendar `c`.
`static Timestamp`
`toTimestamp(LocalDateTime val, @Nullable Calendar c)`
Converts a local date time to a timestamp using calendar `c`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### toLocalDateTime

public static LocalDateTime toLocalDateTime(Timestamp val, @Nullable Calendar c)
Converts a timestamp to a local date time using calendar `c`.

If `c` is null, or the time zone is equal to the JVM default time zone, conversion is performed using `Timestamp.toLocalDateTime()` instead of `c`.

Parameters:
  `val` - timestamp
  `c` - calendar
Returns:
  local date time

### toTimestamp

public static Timestamp toTimestamp(LocalDateTime val, @Nullable Calendar c)
Converts a local date time to a timestamp using calendar `c`.

If `c` is null, or the time zone is equal to the JVM default time zone, conversion is performed using `Timestamp.valueOf(LocalDateTime)` instead of `c`.

Parameters:
  `val` - local date time
  `c` - calendar
Returns:
  timestamp

### toLocalTime

public static LocalTime toLocalTime(Time val, @Nullable Calendar c)
Converts a time to a local time using calendar `c`.

If `c` is null, or the time zone is equal to the JVM default time zone, conversion is performed using `Time.toLocalTime()` instead of `c`.

Parameters:
  `val` - time
  `c` - calendar
Returns:
  local time

### toTime

public static Time toTime(LocalTime val, @Nullable Calendar c)
Converts a local time to a time using calendar `c`.

If `c` is null, or the time zone is equal to the JVM default time zone, conversion is performed using `Time.valueOf(LocalTime)` instead of `c`.

Parameters:
  `val` - local time
  `c` - calendar
Returns:
  time

### toLocalDate

public static LocalDate toLocalDate(Date val, @Nullable Calendar c)
Converts a date to a local date using calendar `c`.

If `c` is null, or the time zone is equal to the JVM default time zone, conversion is performed using `Date.toLocalDate()` instead of `c`.

Parameters:
  `val` - time
  `c` - calendar
Returns:
  local time

### toDate

public static Date toDate(LocalDate val, @Nullable Calendar c)
Converts a local date to a date using calendar `c`.

If `c` is null, or the time zone is equal to the JVM default time zone, conversion is performed using `Date.valueOf(LocalDate)` instead of `c`.

Parameters:
  `val` - local time
  `c` - calendar
Returns:
  time