Created
May 14, 2019 03:52
-
-
Save esabook/da88ac05fa2971e0dc4e7c2985acee03 to your computer and use it in GitHub Desktop.
get localized date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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