JDBC Timestamp & Date GMT issues

前端 未结 5 1083
夕颜
夕颜 2021-02-06 05:20

I have a JDBC Date column, which if a i use getDate is get the \'date\' part only 02 Oct 2009 but if i use getTimestamp i get the full \'date\

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-06 05:52

    private Date convertDate(Date date1) throws ParseException {
            SimpleDateFormat sdfFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String dateStr = sdfFormatter.format(date1);
            SimpleDateFormat sdfParser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            sdfParser.setTimeZone(TimeZone.getTimeZone("GMT"));
            return sdfParser.parse(dateStr);
        }
    

提交回复
热议问题