java - Day light saving issue -
using following : public static void main(string[] args) throws parseexception { system.out.println(convertdate("2017-03-12 02:00", true)); } public static date convertdate(final string datestr, final boolean isdatetime) throws parseexception{ date tmpdate = null; if ( datestr == null || datestr.isempty() ) { return tmpdate; } string dateformat = "yyyy-mm-dd"; // logger.debug("input date string: " + datestr); if (isdatetime) { dateformat = "yyyy-mm-dd hh:mm"; // timezone frtimezone = timezone.gettimezone("utc"); // sdf.settimezone(frtimezone); } simpledateformat sdf = new simpledateformat(dateformat); try { tmpdate = sdf.parse(datestr); } catch (parseexception e) { } return tmpdate; } output getting : sun mar 12 0