日期:2014-05-20 浏览次数:20835 次
TimeZone estZone = TimeZone.getTimeZone("EST"); SimpleDateFormat sdfEST = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); sdfEST.setTimeZone(estZone); Calendar calendar = Calendar.getInstance(); calendar.setTimeZone(estZone); calendar.setTime(sdfEST.parse("2010-10-11 12:13:14")); System.out.println(sdfEST.format(calendar.getTime())); Calendar cal = new GregorianCalendar(); cal.set(Calendar.YEAR, calendar.get(Calendar.YEAR)); cal.set(Calendar.MONTH, calendar.get(Calendar.MONTH)); cal.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH)); cal.set(Calendar.HOUR, calendar.get(Calendar.HOUR)); cal.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE)); cal.set(Calendar.SECOND, calendar.get(Calendar.SECOND)); System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cal.getTime()));