Code example for TimeZone

Methods: getOffset

0
		return toUtc(date, TimeZone.getDefault());
	} 
 
	public static Date toUtc(Date date, TimeZone timeZone) {
		long millis = date.getTime();
		int offset = timeZone.getOffset(millis);
		return new Date(millis - offset);
	} 
 
	public static Date toTimeZone(Date date, TimeZone timeZone) {
		long millis = date.getTime();
		int offset = timeZone.getOffset(millis);
		return new Date(millis + offset);
	} 
 
	public static Date toLocalTime(Date date) {
		return toTimeZone(date, TZ_GMT);
	} 
 
	public static boolean isSameDay(Date day1, Date day2) {
Experience pair programming with AI  Get Codota for Java