-
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.
For all Date & Time related classes, their conversion to Map will consistently have "date" and "time" keys, a "zone" or "offset" key, and "epochMillis" (and "epochNanos" when appropriate)
- Loading branch information
Showing
14 changed files
with
304 additions
and
356 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 |
---|---|---|
|
@@ -18,8 +18,6 @@ | |
|
||
import com.cedarsoftware.util.CompactLinkedMap; | ||
|
||
import static com.cedarsoftware.util.convert.Converter.VALUE; | ||
|
||
/** | ||
* @author Kenny Partlow ([email protected]) | ||
* <br> | ||
|
@@ -147,7 +145,11 @@ static String toString(Object from, Converter converter) { | |
static Map<String, Object> toMap(Object from, Converter converter) { | ||
Date date = (Date) from; | ||
Map<String, Object> map = new CompactLinkedMap<>(); | ||
map.put(VALUE, date.getTime()); | ||
ZonedDateTime zdt = toZonedDateTime(date, converter); | ||
map.put(MapConversions.DATE, zdt.toLocalDate().toString()); | ||
map.put(MapConversions.TIME, zdt.toLocalTime().toString()); | ||
map.put(MapConversions.ZONE, converter.getOptions().getZoneId().toString()); | ||
map.put(MapConversions.EPOCH_MILLIS, date.getTime()); | ||
return map; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
import java.time.Instant; | ||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.ZoneId; | ||
import java.time.LocalTime; | ||
import java.time.ZonedDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.Calendar; | ||
|
@@ -16,8 +16,6 @@ | |
|
||
import com.cedarsoftware.util.CompactLinkedMap; | ||
|
||
import static com.cedarsoftware.util.convert.Converter.VALUE; | ||
|
||
/** | ||
* @author Kenny Partlow ([email protected]) | ||
* <br> | ||
|
@@ -52,8 +50,8 @@ static LocalDateTime toLocalDateTime(Object from, Converter converter) { | |
} | ||
|
||
static ZonedDateTime toZonedDateTime(Object from, Converter converter) { | ||
ZoneId zoneId = converter.getOptions().getZoneId(); | ||
return ((LocalDate) from).atStartOfDay(zoneId); | ||
LocalDate localDate = (LocalDate) from; | ||
return ZonedDateTime.of(localDate, LocalTime.parse("00:00:00"), converter.getOptions().getZoneId()); | ||
} | ||
|
||
static double toDouble(Object from, Converter converter) { | ||
|
@@ -102,7 +100,7 @@ static String toString(Object from, Converter converter) { | |
static Map<String, Object> toMap(Object from, Converter converter) { | ||
LocalDate localDate = (LocalDate) from; | ||
Map<String, Object> target = new CompactLinkedMap<>(); | ||
target.put(VALUE, localDate.toString()); | ||
target.put(MapConversions.DATE, localDate.toString()); | ||
return target; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -11,8 +11,11 @@ | |
import java.time.format.DateTimeFormatter; | ||
import java.util.Calendar; | ||
import java.util.Date; | ||
import java.util.Map; | ||
import java.util.concurrent.atomic.AtomicLong; | ||
|
||
import com.cedarsoftware.util.CompactLinkedMap; | ||
|
||
/** | ||
* @author Kenny Partlow ([email protected]) | ||
* <br> | ||
|
@@ -100,4 +103,12 @@ static String toString(Object from, Converter converter) { | |
LocalDateTime localDateTime = (LocalDateTime) from; | ||
return localDateTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME); | ||
} | ||
|
||
static Map toMap(Object from, Converter converter) { | ||
LocalDateTime localDateTime = (LocalDateTime) from; | ||
Map<String, Object> target = new CompactLinkedMap<>(); | ||
target.put(MapConversions.DATE, localDateTime.toLocalDate().toString()); | ||
target.put(MapConversions.TIME, localDateTime.toLocalTime().toString()); | ||
return target; | ||
} | ||
} |
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.