2011-01-28 38 views
0

我想知道如何選擇小時而不是日期[月,年,日]。如何選擇小時而不是日期

我使用這段代碼:

entity - class ~. domain.Availability --testAutomatically --identifierField 
date field --fieldName begin - notnull --type java.util.Date --past 
field date --end fieldName - notnull --type java.util.Date --past 
field reference --fieldName teacher --type ~. domain.Teacher --notnull 

運行在瀏覽器的代碼,日曆顯示選擇的年,月,日。 我只想挑選一天中的某個時間。 例如開始:08:00小時 結束:12:00小時

乾杯,

回答

0

據的Javadoc @DateTimeFormat

對於基於樣式的格式設置,請將style()屬性設置爲樣式模式代碼。

代碼的第一個字符是日期樣式,第二個字符是時間樣式。指定短字符爲'S',中字符爲'M',長字符爲'L',填充爲'F'。通過指定樣式字符'-'可以省略日期或時間。

@DateTimeFormat(style = "-F")

0

您可以嘗試這樣做。

focus --class ~.domain.YourEntity 
field date --fieldName yourfield --type java.util.Date --dateTimeFormatPattern "hh:mm" 

這種形式更好,從檔案.java,獨自寫它。

/** 
*/ 
@Temporal(TemporalType.TIMESTAMP) 
@DateTimeFormat(style = "-S") 
private Date yourhours; 
相關問題