-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calendar conversions are now matching the rest of the Temporal conver…
…sions, where Double and BigDecimal represent fractional seconds, Long represents milliseconds, and BigInteger represents nanoseconds.
- Loading branch information
Showing
7 changed files
with
219 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,9 @@ | |
import java.time.LocalTime; | ||
import java.time.OffsetDateTime; | ||
import java.time.ZonedDateTime; | ||
import java.util.Calendar; | ||
import java.util.Date; | ||
import java.util.GregorianCalendar; | ||
|
||
/** | ||
* @author John DeRegnaucourt ([email protected]) | ||
|
@@ -47,6 +49,15 @@ static Date toSqlDate(Object from, Converter converter) { | |
return new java.sql.Date((long)(d * 1000)); | ||
} | ||
|
||
static Calendar toCalendar(Object from, Converter converter) { | ||
double seconds = (double) from; | ||
long epochMillis = (long)(seconds * 1000); | ||
Calendar calendar = GregorianCalendar.getInstance(converter.getOptions().getTimeZone()); | ||
calendar.clear(); | ||
calendar.setTimeInMillis(epochMillis); | ||
return calendar; | ||
} | ||
|
||
static LocalTime toLocalTime(Object from, Converter converter) { | ||
double seconds = (double) from; | ||
double nanos = seconds * 1_000_000_000.0; | ||
|
Oops, something went wrong.