List of utility methods to do Date UTC Parse
Date | uTCToChinaTS(Date date) u TC To China TS Calendar ca = Calendar.getInstance();
ca.setTime(date);
ca.add(Calendar.HOUR, 8);
return ca.getTime();
|
Date | UTCToDate(long utcValue) UTC To Date Date date = null; Calendar calendar = Calendar.getInstance(); calendar.set(1970, 0, 1, 8, 0, 0); long start = calendar.getTimeInMillis(); long end = start + 1000 * utcValue; date = new Date(end); return date; |
Date | utcToLocal(Date utcDate) utc To Local long utcMiliseconds = utcDate.getTime(); Calendar cal = new GregorianCalendar(); cal.setTimeInMillis(utcMiliseconds); return new Date(utcMiliseconds + cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)); |