Java | android timezone taipei
摘要:Java-SimpleDateFormat以格林威治及台北時間解析 在使用SimpleDateFormat,預設就是用該電腦的時區為主, 在本機是台灣,上傳到了原端主機(國外虛擬主機)時區就變了, 導致在台灣設定的晚上八點,到了國外主機,就變成了中午十二點。 因此,就要將時區設定到SimpleDateFormat 格林威治,如下 SimpleDateFormatsdf=newSimpleDateFormat("yyyy-MM-dd"); sdf.setTimeZone(TimeZone.getTimeZone("GMT")); 台北時間,如下 SimpleDateFormatsdf=newSimpleDateFor...
摘要:Java - SimpleDateFormat 以格林威治及台北時間解析
在使用SimpleDateFormat,預設就是用該電腦的時區為主,
在本機是台灣,上傳到了原端主機(國外虛擬主機)時區就變了,
導致在台灣設定的晚上八點,到了國外主機,就變成了中午十二點。
因此,就要將時區設定到SimpleDateFormat
格林威治,如下
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
台北時間,如下
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
sdf.setTimeZone(TimeZone.getTimeZone("Asia/Taipei"));