From e3de5aab40b128614b5ee310e74b76d1094ce014 Mon Sep 17 00:00:00 2001 From: Jake Esser Date: Thu, 9 Nov 2023 13:37:30 +0100 Subject: [PATCH] Fxied DateFormat annotation issue --- .../javawebstack/abstractdata/mapper/DefaultMappers.java | 2 +- .../abstractdata/mapper/annotation/DateFormat.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/javawebstack/abstractdata/mapper/DefaultMappers.java b/src/main/java/org/javawebstack/abstractdata/mapper/DefaultMappers.java index 2ed0b60..0a7a682 100644 --- a/src/main/java/org/javawebstack/abstractdata/mapper/DefaultMappers.java +++ b/src/main/java/org/javawebstack/abstractdata/mapper/DefaultMappers.java @@ -263,7 +263,7 @@ public AbstractElement toAbstract(MapperContext context, Object value) throws Ma public Object fromAbstract(MapperContext context, AbstractElement element, Class type) throws MapperException { try { - DateFormat df = context.getAnnotation(DateFormat.class); + DateFormat df = context.getField().getAnnotation(DateFormat.class); Date date; if (df != null && df.epoch()) { long time = element.number(context.getMapper().isStrict()).longValue(); diff --git a/src/main/java/org/javawebstack/abstractdata/mapper/annotation/DateFormat.java b/src/main/java/org/javawebstack/abstractdata/mapper/annotation/DateFormat.java index bcedb86..d752599 100644 --- a/src/main/java/org/javawebstack/abstractdata/mapper/annotation/DateFormat.java +++ b/src/main/java/org/javawebstack/abstractdata/mapper/annotation/DateFormat.java @@ -1,5 +1,12 @@ package org.javawebstack.abstractdata.mapper.annotation; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) public @interface DateFormat { String value() default "";