Add DateUtils.toCalendar(Date, TimeZone)

This commit is contained in:
Kaiyuan Wang 2016-09-20 23:58:36 -05:00
parent db6f7c1d74
commit 1eecfc948b
1 changed files with 13 additions and 0 deletions

View File

@ -666,6 +666,19 @@ public class DateUtils {
return c;
}
//-----------------------------------------------------------------------
/**
* Converts a {@code Date} of a given {@code TimeZone} into a {@code Calendar}
* @param date the date to convert to a Calendar
* @param timeZone the time zone of the @{code date}
* @return
*/
public static Calendar toCalendar(final Date date, final TimeZone tz) {
final Calendar c = Calendar.getInstance(tz);
c.setTime(date);
return c;
}
//-----------------------------------------------------------------------
/**
* <p>Rounds a date, leaving the field specified as the most