Java Utililty Methods Date UTC Parse

List of utility methods to do Date UTC Parse

Description

The list of methods to do Date UTC Parse are organized into topic(s).

Method

DateuTCToChinaTS(Date date)
u TC To China TS
Calendar ca = Calendar.getInstance();
ca.setTime(date);
ca.add(Calendar.HOUR, 8);
return ca.getTime();
DateUTCToDate(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;
DateutcToLocal(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));