Skip to content

Instantly share code, notes, and snippets.

@takuya-i
Created June 30, 2015 13:24
Show Gist options
  • Save takuya-i/f1ac4ba2acece215d64b to your computer and use it in GitHub Desktop.
Save takuya-i/f1ac4ba2acece215d64b to your computer and use it in GitHub Desktop.
AndroidでrailsのDateTimeをパースし、ローカルロケール時刻テキストに変換 ref: http://qiita.com/takuya-i/items/c48fac398b6715596a8c
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