Last active
August 29, 2015 14:13
-
-
Save alvintamie/5a692454d588b187cd47 to your computer and use it in GitHub Desktop.
Java Parse Time with Timezone
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
import java.text.DateFormat; | |
import java.text.SimpleDateFormat; | |
import java.text.ParseException; | |
import java.util.Date; | |
import java.util.TimeZone; | |
public class ParseTimeWithTimezone{ | |
public static void main(String []args){ | |
try { | |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); | |
Date date = sdf.parse("2015-01-16T09:00:00.000+08:00"); | |
sdf.setTimeZone(TimeZone.getTimeZone("Asia/Singapore")); | |
System.out.println(sdf.format(date)); | |
} | |
catch (Exception e) { | |
//The handling for the code | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment