Skip to content

Instantly share code, notes, and snippets.

@esabook
Created May 14, 2019 03:52
Show Gist options
  • Save esabook/da88ac05fa2971e0dc4e7c2985acee03 to your computer and use it in GitHub Desktop.
Save esabook/da88ac05fa2971e0dc4e7c2985acee03 to your computer and use it in GitHub Desktop.
get localized date
/**
* @param date
* @return
*/
public static Date getLocalizedDate(Date date) {
try {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.MILLISECOND, TimeZone.getDefault().getRawOffset());
return c.getTime();
} catch (Exception e) {
return date;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment