| | |
| | | import java.sql.Timestamp; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.ZonedDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | |
| | | return value; |
| | | } |
| | | |
| | | //2.0 Date 转 Date |
| | | if (value instanceof LocalDateTime && target == Date.class) { |
| | | ZoneId zoneId = ZoneId.systemDefault(); |
| | | ZonedDateTime zonedDateTime = ((LocalDateTime)value).atZone(zoneId); |
| | | Date date = Date.from(zonedDateTime.toInstant()); |
| | | return date; |
| | | } |
| | | |
| | | |
| | | // 3.0 Date 转 String |
| | | if (value instanceof Date && target == String.class) { |
| | | Date date = (Date) value; |