'2009-12 Dec' should be converted to '31-DEC-2009'
'2010-09 Sep' should be converted to '30-SEP-2010'
'2010-02 Feb' should be converted to '28-FEB-2010'
'2008-02 Feb' should be converted to '29-FEB-2008'
値2009-12Dec、2008-02Febがドロップダウンでユーザーに表示されます。ユーザーには、曜日を選択するオプションがありません。
ユーザーが選択した値をデータベースに渡す必要があります。ただし、データベースは次の形式の日付を想定していますDD-MMM-YYYY
。クエリには' <= USER_DATE
'条件があります。したがって、月の最終日が自動的に選択され、データベースに渡される必要があります。
Plは、上記の仕事をする関数を書くのを手伝ってくれます。
static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM MMM");
public static String convertMapedToSqlFormat(final String maped) {
String convertedMaped = null;
//....
return convertedMaped;
}
@Test
public void testConvertMapedToSqlFormat() {
String[] mapedValues = { "2009-12 Dec", "2009-11 Nov", "2009-10 Oct",
"2009-09 Sep", "2009-08 Aug", "2009-07 Jul", "2009-06 Jun",
"2009-05 May", "2009-04 Apr", "2009-03 Mar", "2009-02 Feb",
"2009-01 Jan", "2008-12 Dec", "2008-11 Nov", "2008-10 Oct" };
for (String maped : mapedValues) {
System.out.println(convertMapedToSqlFormat(maped));
}
}