Your pattern does not correspond to the input string at all… It is not surprising that it does not work. This would probably work better:
SimpleDateFormat sdf = new SimpleDateFormat("EE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
Then to print with your required format you need a second SimpleDateFormat:
Date parsedDate = sdf.parse(date); SimpleDateFormat print = new SimpleDateFormat("MMM d, yyyy HH:mm:ss"); System.out.println(print.format(parsedDate));
Notes:
- you should include the locale as if your locale is not English, the day name might not be recognised
- IST is ambiguous and can lead to problems so you should use the proper time zone name if possible in your input.
Related Posts:
- What is an instance variable in Java?
- super() in Java
- What’s the syntax for mod in java
- What does the Java assert keyword do, and when should it be used?
- How do I make a delay in Java?
- Casting variables in Java
- max value of integer
- How can I prevent java.lang.NumberFormatException: For input string: “N/A”?
- What is the difference between == and equals() in Java?
- What does “?” mean in Java?
- Java – No enclosing instance of type Foo is accessible
- Why I am getting java.lang.AbstractMethodError errors?
- fix java.net.SocketTimeoutException: Read timed out
- How to override equals method in Java
- Java – String cannot be converted to int
- java.io.IOException: Broken pipe
- java.util.NoSuchElementException: No line found
- Even though JRE 8 is installed on my MAC -” No Java Runtime present,requesting to install ” gets displayed in terminal
- Reason for the exception java.lang.VerifyError: Bad type on operand stack
- The specified DSN contains an architecture mismatch between the Driver and Application. JAVA
- Downcasting in Java
- Java “params” in method signature?
- How do I time a method’s execution in Java?
- repaint() Method in Java
- Exception in thread “main” java.lang.reflect.InvocationTargetException
- How to set String’s font size, style in Java using the Font class?
- How to use the command update-alternatives –config java
- java array error “array required but int found”
- this: Cannot use this in static context
- How to convert an Instant to a date format?
- What’s the difference between SoftReference and WeakReference in Java?
- How to draw lines in Java
- NoClassDefFoundError in Java: com/google/common/base/Function
- In Java, what is a shallow copy?
- Good way to encapsulate Integer.parseInt()
- Eclipse IDE – Error: Build path specifies execution environment Java SE 1.7
- Java: Not a statement
- ArrayList of int array in java
- How to get the filename without the extension in Java?
- How can I upgrade to Java 1.8 on an Amazon Linux Server?
- Can’t start Eclipse – Java was started but returned exit code=13
- Visual List of iOS Fonts?
- Is there a way to convert all comments into javadoc comments? [Eclipse/Java]
- Reverse a string in Java
- How to get rid of the “No bootable medium found!” error in Virtual Box? [closed]
- How can I solve “java.lang.NoClassDefFoundError”?
- “Char cannot be dereferenced” error
- Does Java have an exponential operator?
- Non-static variable cannot be referenced from a static context
- SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”
- SSH -X “Warning: untrusted X11 forwarding setup failed: xauth key data not generated”
- Best way to Format a Double value to 2 Decimal places
- Collision resolution in Java HashMap
- LINQ equivalent of foreach for IEnumerable
- What are the differences between char literals ‘\n’ and ‘\r’ in Java?
- “Content is not allowed in prolog” when parsing perfectly valid XML on GAE
- “java.lang.OutOfMemoryError : unable to create new native Thread”
- java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
- How do I use a delimiter with Scanner.useDelimiter in Java?
- Sort a single String in Java
- Difference between slf4j-log4j12 and log4j-over-slf4j
- Java, “Variable name” cannot be resolved to a variable
- How to use vmImage on pipeline using Azure DevOps Server?
- What is Java String interning?
- Is there a destructor for Java?
- What condition does while(true) test? When is it true and false?
- imageio.IIOException: Can’t read input file
- Difference between OpenJDK and Adoptium/AdoptOpenJDK
- PostgreSQL: Remotely connecting to Postgres instance using psql command
- Compile failed; see the compiler error output for details
- Java Error opening registry key
- Java: Rotating Images
- Invalid character constant in java
- How to pass a function as a parameter in Java?
- ResultSet exception – before start of result set
- The activity must be exported or contain an intent-filter
- How to solve error lossy convertion from int to char?
- What does “error: ‘.class’ expected” mean and how do I fix it
- Plotting horizontal and vertical lines in Mathematica
- Error while waiting for device: Time out after 300seconds waiting for emulator to come online
- Most efficient way to increment a Map value in Java
- Printing the stack values in Java
- Import a custom class in Java
- How to send HTTP request in java?
- How to take input as String with spaces in java using scanner
- Differentiate between function overloading and function overriding
- Address already in use: JVM_Bind java
- Java – Change int to ascii
- Adding JPanel to JFrame
- Append a single character to a string or char array in java?
- What standard do language codes of the form “zh-Hans” belong to?
- Can’t load IA 32-bit .dll on a AMD 64-bit platform
- Android Studio 2.2.3: Gradle project sync failed. Basic functionality (e.g. editting, debugging) will not work properly
- Java associative-array
- How to draw a circle with given X and Y coordinates as the middle spot of the circle?
- In Java, how do I parse XML as a String instead of a file?
- What is the proof of of (N–1) + (N–2) + (N–3) + … + 1= N*(N–1)/2
- Java Returning method which returns arraylist?
- How to hide subfolder of static pages in WordPress using htaccess
- How do I deal with a compromised server?