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 1096739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:19:31+00:00 2026-05-17T00:19:31+00:00

Earlier I posted the following question: How can I convert this date in Java?

  • 0

Earlier I posted the following question: How can I convert this date in Java?

But now I would like to know how I can convert this string into a date/time.

2010-03-15T16:34:46Z

For example: 03/15/10

UPDATED:

String pattern = "MM/dd/yy 'at' HH:mm";
                Date date = new Date();
                try {
                    date = new SimpleDateFormat(pattern).parse(q.getUpdated_at());
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                dateText.setText(new SimpleDateFormat("MM/dd/yy 'at' hh:mma").format(date));

Gives me a result like:

Mon Mar 15 16:34:50 MST 2010

How can I format it to be

03/15/10 at 4:34PM

?

  • 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-05-17T00:19:32+00:00Added an answer on May 17, 2026 at 12:19 am

    In a nutshell, you want to convert a date in a string format to a date in another string format. You have:

    2010-03-15T16:34:46Z
    

    and you want

    03/15/10 at 4:34PM
    

    You don’t want to end up using java.util.Date object as you initially implied in your question. You also don’t want to use its toString() since that returns a fixed format as definied in its javadoc.

    The answer of Bozho still applies. Use java.text.SimpleDateFormat. First, you need to parse the date in string format into a Date object so that you can format it back into another string format.

    // First parse string in pattern "yyyy-MM-dd'T'HH:mm:ss'Z'" to date object.
    String dateString1 = "2010-03-15T16:34:46Z";
    Date date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").parse(dateString1);
    
    // Then format date object to string in pattern "MM/dd/yy 'at' h:mma".
    String dateString2 = new SimpleDateFormat("MM/dd/yy 'at' h:mma").format(date);
    System.out.println(dateString2); // 03/15/10 at 4:34PM
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.