Java SimpleDateFormat(“yyyy-MM-dd’T’HH:mm:ss’Z'”) gives timezone as IST

I have SimpleDateFormat constructor as SimpleDateFormat(“yyyy-MM-dd’T’HH:mm:ss’Z'”) and I am parsing string “2013-09-29T18:46:19Z”. I have read that here Z represents the GMT/UTC timezone. but when I print this date on console , It prints IST timezne for the returned date. Now my question is whether my output is right or wrong? 8 Answers 8

How to parse a date? [duplicate]

This question already has answers here: Java string to date conversion (17 answers) Closed 5 years ago. I am trying to parse this date with SimpleDateFormat and it is not working: import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Formaterclass { public static void main(String[] args) throws ParseException{ String strDate = “Thu Jun 18 20:56:02 … Read more

Convert String to Calendar Object in Java

I am new to Java, usually work with PHP. I am trying to convert this string: Mon Mar 14 16:02:37 GMT 2011 Into a Calendar Object so that I can easily pull the Year and Month like this: String yearAndMonth = cal.get(Calendar.YEAR)+cal.get(Calendar.MONTH); Would it be a bad idea to parse it manually? Using a substring … Read more

Illegal pattern character ‘T’ when parsing a date string to java.util.Date

I have a date string and I want to parse it to normal date use the java Date API,the following is my code: public static void main(String[] args) { String date=”2010-10-02T12:23:23Z”; String pattern=”yyyy-MM-ddThh:mm:ssZ”; SimpleDateFormat sdf=new SimpleDateFormat(pattern); try { Date d=sdf.parse(date); System.out.println(d.getYear()); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } However … Read more

Why is Java’s SimpleDateFormat not thread-safe? [duplicate]

This question already has answers here: “Java DateFormat is not threadsafe” what does this leads to? (11 answers) Closed 5 years ago. Please tell with a code example why is SimpleDateFormat not threadsafe. What is the problem in this class? Is The problem with format function of SimpleDateFormat? Please give a code which demonstrates this … Read more

What is this date format? 2011-08-12T20:17:46.384Z

I have the following date: 2011-08-12T20:17:46.384Z. What format is this? I’m trying to parse it with Java 1.4 via DateFormat.getDateInstance().parse(dateStr) and I’m getting java.text.ParseException: Unparseable date: “2011-08-12T20:17:46.384Z” I think I should be using SimpleDateFormat for parsing, but I have to know the format string first. All I have for that so far is yyyy-MM-dd, because … Read more