-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from pugwoo/develop-daily
release 1.1.7
- Loading branch information
Showing
17 changed files
with
318 additions
and
57 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
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
42 changes: 42 additions & 0 deletions
42
src/main/java/com/pugwoo/wooutils/json/MultiLocalDateDeserializer.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,42 @@ | ||
package com.pugwoo.wooutils.json; | ||
|
||
import com.fasterxml.jackson.core.JsonParseException; | ||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; | ||
import com.pugwoo.wooutils.lang.DateUtils; | ||
import com.pugwoo.wooutils.string.StringTools; | ||
|
||
import java.io.IOException; | ||
import java.time.LocalDate; | ||
|
||
public class MultiLocalDateDeserializer extends StdDeserializer<LocalDate> { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
public MultiLocalDateDeserializer() { | ||
this(null); | ||
} | ||
public MultiLocalDateDeserializer(Class<?> vc) { | ||
super(vc); | ||
} | ||
|
||
@Override | ||
public LocalDate deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { | ||
JsonNode node = jp.getCodec().readTree(jp); | ||
String date = node.asText(); | ||
if (StringTools.isBlank(date)) { // 这个判空是因为parseLocalDate中没有判空 | ||
return null; | ||
} | ||
|
||
LocalDate localDate = DateUtils.parseLocalDate(date); | ||
if (localDate == null) { | ||
throw new JsonParseException(jp, | ||
"Unparseable localDate: \"" + date + "\". Supported formats: " | ||
+ DateUtils.DATE_FORMAT_REGEXPS.values()); | ||
} | ||
return localDate; | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/pugwoo/wooutils/json/MultiLocalDateTimeDeserializer.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,42 @@ | ||
package com.pugwoo.wooutils.json; | ||
|
||
import com.fasterxml.jackson.core.JsonParseException; | ||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; | ||
import com.pugwoo.wooutils.lang.DateUtils; | ||
import com.pugwoo.wooutils.string.StringTools; | ||
|
||
import java.io.IOException; | ||
import java.time.LocalDateTime; | ||
|
||
public class MultiLocalDateTimeDeserializer extends StdDeserializer<LocalDateTime> { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
public MultiLocalDateTimeDeserializer() { | ||
this(null); | ||
} | ||
public MultiLocalDateTimeDeserializer(Class<?> vc) { | ||
super(vc); | ||
} | ||
|
||
@Override | ||
public LocalDateTime deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { | ||
JsonNode node = jp.getCodec().readTree(jp); | ||
String date = node.asText(); | ||
if (StringTools.isBlank(date)) { // 这个判空是因为parseLocalDate中没有判空 | ||
return null; | ||
} | ||
|
||
LocalDateTime localDateTime = DateUtils.parseLocalDateTime(date); | ||
if (localDateTime == null) { | ||
throw new JsonParseException(jp, | ||
"Unparseable localDateTime: \"" + date + "\". Supported formats: " | ||
+ DateUtils.DATE_FORMAT_REGEXPS.values()); | ||
} | ||
return localDateTime; | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/pugwoo/wooutils/json/MultiLocalTimeDeserializer.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,42 @@ | ||
package com.pugwoo.wooutils.json; | ||
|
||
import com.fasterxml.jackson.core.JsonParseException; | ||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; | ||
import com.pugwoo.wooutils.lang.DateUtils; | ||
import com.pugwoo.wooutils.string.StringTools; | ||
|
||
import java.io.IOException; | ||
import java.time.LocalTime; | ||
|
||
public class MultiLocalTimeDeserializer extends StdDeserializer<LocalTime> { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
public MultiLocalTimeDeserializer() { | ||
this(null); | ||
} | ||
public MultiLocalTimeDeserializer(Class<?> vc) { | ||
super(vc); | ||
} | ||
|
||
@Override | ||
public LocalTime deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { | ||
JsonNode node = jp.getCodec().readTree(jp); | ||
String date = node.asText(); | ||
if (StringTools.isBlank(date)) { // 这个判空是因为parseLocalDate中没有判空 | ||
return null; | ||
} | ||
|
||
LocalTime localTime = DateUtils.parseLocalTime(date); | ||
if (localTime == null) { | ||
throw new JsonParseException(jp, | ||
"Unparseable localTime: \"" + date + "\". Supported formats: " | ||
+ DateUtils.DATE_FORMAT_REGEXPS.values()); | ||
} | ||
return localTime; | ||
} | ||
|
||
} |
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.