2011-06-21 105 views
0

我遇到數據問題。我有一個班,我有安裝者和獲得者。使用curl我需要顯示數據和其他東西。我正在使用碼頭服務器。這是從我的類代碼,我用它來獲取數據:彈簧和數據問題

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

    return date; 
} 


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

,這是結果:enter image description here

這是我在控制檯中看到: [{「createdAt」:1308649398723,「期間」 :0,「date」:1308649398723,「updatedAt」:null,「id」:null}]

我想知道如何在YYYY-MM-DD-HH-MM-SS上更改數據格式。 我補充一下:

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 

    } 
} 

,改變

@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; 
} 

,但仍不能工作

+1

該圖片太小而無法讀取 - 只需剪切並粘貼文本! –

回答

1

應設置patternDateTimeFormat註釋,而不是iso屬性。