-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
191 additions
and
210 deletions.
There are no files selected for viewing
59 changes: 0 additions & 59 deletions
59
core/src/main/java/org/gbif/vocabulary/persistence/handlers/LocalDateTimeTypeHandler.java
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
core/src/main/java/org/gbif/vocabulary/persistence/handlers/ZonedDateTimeTypeHandler.java
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.gbif.vocabulary.persistence.handlers; | ||
|
||
import java.sql.CallableStatement; | ||
import java.sql.PreparedStatement; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Timestamp; | ||
import java.time.ZoneId; | ||
import java.time.ZonedDateTime; | ||
import org.apache.ibatis.type.BaseTypeHandler; | ||
import org.apache.ibatis.type.JdbcType; | ||
|
||
/** | ||
* @author Tomas Rohovsky | ||
*/ | ||
public class ZonedDateTimeTypeHandler extends BaseTypeHandler<ZonedDateTime> { | ||
|
||
@Override | ||
public void setNonNullParameter( | ||
PreparedStatement ps, int i, ZonedDateTime parameter, JdbcType jdbcType) throws SQLException { | ||
ps.setTimestamp(i, Timestamp.from(parameter.toInstant())); | ||
} | ||
|
||
@Override | ||
public ZonedDateTime getNullableResult(ResultSet rs, String columnName) throws SQLException { | ||
Timestamp timestamp = rs.getTimestamp(columnName); | ||
return getZonedDateTime(timestamp); | ||
} | ||
|
||
@Override | ||
public ZonedDateTime getNullableResult(ResultSet rs, int columnIndex) throws SQLException { | ||
Timestamp timestamp = rs.getTimestamp(columnIndex); | ||
return getZonedDateTime(timestamp); | ||
} | ||
|
||
@Override | ||
public ZonedDateTime getNullableResult(CallableStatement cs, int columnIndex) | ||
throws SQLException { | ||
Timestamp timestamp = cs.getTimestamp(columnIndex); | ||
return getZonedDateTime(timestamp); | ||
} | ||
|
||
private static ZonedDateTime getZonedDateTime(Timestamp timestamp) { | ||
if (timestamp != null) { | ||
return ZonedDateTime.ofInstant(timestamp.toInstant(), ZoneId.systemDefault()); | ||
} | ||
return null; | ||
} | ||
} |
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
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
Oops, something went wrong.