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

  • SEARCH
  • Home
  • 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 9098029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:15:53+00:00 2026-06-17T00:15:53+00:00

I have this code to convert a string to a date. but the resulting

  • 0

I have this code to convert a string to a date. but the resulting date is always in another format.

SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm");
        try {
            String dateString  = "18/01/2013 11:59";
            dateTest = format.parse(dateString);
            System.out.println(dateTest); //output: Tue Jan 18 11:59:00 GMT 2013
           }

How can I make it so that dateTest is in the same format as the original?

  • 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-17T00:15:56+00:00Added an answer on June 17, 2026 at 12:15 am

    This

    System.out.println(format.format(dateTest));
    

    will do the job. You can use the format() method of your SimpleDateFormat to format the output the same way your input should be.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written this code to convert string in such format 0(532) 222 22
Hi I have this code in RoR to convert String into a date: r.valid_from
I was trying to format a string into date. For this I have written
i have written this code to convert the current system date and time to
I have this code: Hexline - string in hex (080a00000135627c43784... etc) Date = Hexline[:16]
I have a string that contains a date, in the following format: dd-mm-yyyy with
I have a date/time string like 2012-01-13 04:37:20 but I want to convert it
Could anyone please help me convert this code to vb.net, I have tried it
I have a php code like this,and I need to convert it to .NET
I have got some javascript code and I'd like to convert this to C#.

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.