0
我正在從oracle表中提取結果,並且想要設置dd-MMM-yyyy hh:mm的特定日期格式。更改結果集中的日期格式
我不知道在哪個位置或列位置存儲日期。
我試圖檢查列類型並更改日期,但此操作很耗時。
如何轉換此日期?
下面是我的代碼:
if((colType.get(num).equalsIgnoreCase("DATE")))
{
String getDate = rs.getString(colName.get(num));
String convertedDate = "";
if(getDate!=null||!getDate.isEmpty())
{
DateFormat originalFormat = new SimpleDateFormat("MM/dd/yyyy H:m:s");
SimpleDateFormat targetFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm");
Date date = originalFormat.parse(getDate);
convertedDate = targetFormat.format(date);
bw.write(convertedDate);
bw.write("|");
}
}