开发者

Spring and problem with data

I have a pr开发者_JS百科oblem with data. I have a class where I have setters and getters. Using curl I need to show data and others things. I am using jetty server. This is code from my class which I use to get data:

@DateTimeFormat(iso = ISO.DATE_TIME)
public Date getDate() {

    return date;
}


@DateTimeFormat(iso = ISO.DATE_TIME)
public void setDate(Date date) {
    this.date = date;
}

and this is results:

Spring and problem with data

This is what I get in console: [{"createdAt":1308649398723,"period":0,"date":1308649398723,"updatedAt":null,"id":null}]

I would like to know how I can change data format on YYYY-MM-DD-HH-MM-SS. I add :

public void setDate(Date date) {
    this.date = date;
}
@Target( { ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
public @interface DateTimeFormat {

    String style() default "SS";

    org.springframework.format.annotation.DateTimeFormat.ISO iso() ;

    String pattern() default "";

    public enum ISO {

        DATE,

        TIME,

        DATE_TIME,

        NONE

    }
}

and change

@DateTimeFormat(iso = ISO.DATE_TIME,,pattern="M/d/yy h:mm a")
public Date getDate() {

    return date;
}


@DateTimeFormat(iso = ISO.DATE_TIME,,pattern="M/d/yy h:mm a")
public void setDate(Date date) {
    this.date = date;
}

and still not working


You should set the pattern in the DateTimeFormat annotation, instead of the iso attribute.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜