forked from sofastack/sofa-rpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support the compatible conversion for subtypes of Date. (sofastack#307)
- Loading branch information
Showing
4 changed files
with
44 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,11 +25,13 @@ | |
* @author <a href=mailto:[email protected]>GengZhang</a> | ||
*/ | ||
public class ExtensionLoaderFactory { | ||
private ExtensionLoaderFactory() { | ||
} | ||
|
||
/** | ||
* All extension loader {Class : ExtensionLoader} | ||
*/ | ||
public static final ConcurrentMap<Class, ExtensionLoader> LOADER_MAP = new ConcurrentHashMap<Class, ExtensionLoader>(); | ||
private static final ConcurrentMap<Class, ExtensionLoader> LOADER_MAP = new ConcurrentHashMap<Class, ExtensionLoader>(); | ||
|
||
/** | ||
* Get extension loader by extensible class with listener | ||
|
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 |
---|---|---|
|
@@ -28,8 +28,6 @@ | |
import java.util.Set; | ||
|
||
/** | ||
* | ||
* | ||
* @author <a href="mailto:[email protected]">GengZhang</a> | ||
*/ | ||
public class CompatibleTypeUtilsTest { | ||
|
@@ -65,6 +63,18 @@ public void convert() throws Exception { | |
|
||
Date dataTime = DateUtils.strToDate("2018-1-1 11:22:33"); | ||
Assert.assertEquals(dataTime, CompatibleTypeUtils.convert("2018-1-1 11:22:33", Date.class)); | ||
Long timeLong = DateUtils.strToLong("2018-1-1 11:22:33"); | ||
java.sql.Date sqlDate = new java.sql.Date(timeLong); | ||
Object timeResult = CompatibleTypeUtils.convert("2018-1-1 11:22:33", java.sql.Date.class); | ||
Assert.assertEquals(sqlDate, timeResult); | ||
timeResult = CompatibleTypeUtils.convert(timeLong, java.sql.Date.class); | ||
Assert.assertEquals(sqlDate, timeResult); | ||
timeResult = CompatibleTypeUtils.convert("2018-1-1 11:22:33", java.sql.Timestamp.class); | ||
java.sql.Timestamp timestamp = new java.sql.Timestamp(timeLong); | ||
Assert.assertEquals(timestamp, timeResult); | ||
timeResult = CompatibleTypeUtils.convert("2018-1-1 11:22:33", java.sql.Time.class); | ||
java.sql.Time time = new java.sql.Time(timeLong); | ||
Assert.assertEquals(time, timeResult); | ||
|
||
Assert.assertEquals(new Short("123"), CompatibleTypeUtils.convert(123, Short.class)); | ||
Assert.assertEquals(new Short("123"), CompatibleTypeUtils.convert(123, short.class)); | ||
|