Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8000057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:41:01+00:00 2026-06-04T15:41:01+00:00

I am getting a Date format in String as Output like this. Fri May

  • 0

I am getting a Date format in String as Output like this.

Fri May 18 00:00:00 EDT 2012

I need to Convert this to a Date Object. What approach shall I use?

Thank you.

This is the program i used.

import java.util.*;
import java.text.*;

public class DateToString {
    public static void main(String[] args) {
        try {
            DateFormat formatter ;
            Date date ;
            formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss 'EDT' yyyy ");
            date = (Date)formatter.parse("Fri May 18 00:00:00 EDT 2012");
            String s = formatter.format(date);
            System.out.println("Today is " + s);
        } catch (ParseException e) {
            System.out.println("Exception :"+e); 
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:41:02+00:00Added an answer on June 4, 2026 at 3:41 pm

    Use SimpleDateFormat and implementations to get a date displayable in a format you want.

    Example:

    String myDateString = "Fri May 18 00:00:00 EDT 2012";
    SimpleDateFormat dateFormat = new SimpleDateFormat();
    dateFormat.applyPattern( "EEE MMM dd HH:mm:ss z yyyy" );
    
    try {
        Date d = dateFormat.parse( myDateString );
        System.out.println( d ); // Fri May 18 00:00:00 EDT 2012
    
        String datePattern1 = "yyyy-MM-dd";
        dateFormat.applyPattern( datePattern1 );
        System.out.println( dateFormat.format( d ) ); // 2012-05-18
    
        String datePattern2 = "yyyy.MM.dd G 'at' HH:mm:ss z";
        dateFormat.applyPattern( datePattern2 );
        System.out.println( dateFormat.format( d ) ); // 2012.05.18 AD at 00:00:00 EDT
    
        String datePattern3 = "yyyy.MM.dd G 'at' HH:mm:ss Z";
        dateFormat.applyPattern( datePattern3 );
        System.out.println( dateFormat.format( d ) ); // 2012.05.18 AD at 00:00:00 -400
    }
    catch ( Exception e ) { // ParseException
        e.printStackTrace();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my project i am getting 2008-02-01T10:03:23.793-06:00 this date format in string i have
I am getting the date string from the server as 2012-06-21 18:13:33 -04:00 What
I'm getting a date from a Web Service, dd/mm/yyyy hh:mi:ss. Like this: 10/10/2011 12:00:00
I having a problem converting a string into the date format I need. An
I am converting a string into a date object with this code. NSDateFormatter *formate
I am getting a date in this format: 2011-05-23 6:05:00 How can I obtain
I am getting date into string in YYYY/MM/DD HH:MM:SS format.I want to change it
I'm getting unexpected output when running following code, DateFormat df = new SimpleDateFormat(YYYY-MM-dd); Date
I am getting an error in converting string to date in C#. The error
HI, I am converting String to Date format. But it returns wrong dates. for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.