Created
June 30, 2015 13:24
-
-
Save takuya-i/f1ac4ba2acece215d64b to your computer and use it in GitHub Desktop.
AndroidでrailsのDateTimeをパースし、ローカルロケール時刻テキストに変換 ref: http://qiita.com/takuya-i/items/c48fac398b6715596a8c
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
public final static String TIME_FORMAT = "yy/MM/dd HH:mm:ss"; | |
//UTC標準時刻をローカル時間のテキストに変換する。 | |
public String toLocalTime(String utcTime) { | |
try { | |
Time t = new Time(); | |
t.parse3339(utcTime); | |
long msec = t.normalize(false); | |
Date d = new Date( msec ); | |
SimpleDateFormat df = new SimpleDateFormat(); | |
return df.format(d); | |
} catch (TimeFormatException e) { | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment