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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:55:01+00:00 2026-05-29T17:55:01+00:00

I am trying to use the Android SimpleDateFormat like this: String _Date = 2010-09-29

  • 0

I am trying to use the Android SimpleDateFormat like this:

String _Date = "2010-09-29 08:45:22"
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");

try {
    Date date = fmt.parse(_Date);
    return fmt.format(date);
}
catch(ParseException pe) {
    return "Date";    
}

The result is good and I have: 2010-09-29

But if I change the SimpleDateFormat to

SimpleDateFormat("dd-MM-yyyy");

the problem is that I will got 03-03-0035 !!!!

Why and how to get the format like dd-MM-yyyy?

  • 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-29T17:55:02+00:00Added an answer on May 29, 2026 at 5:55 pm

    I assume you would like to reverse the date format?

    SimpleDateFormat can be used for parsing and formatting.
    You just need two formats, one that parses the string and the other that returns the desired print out:

    SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
    Date date = fmt.parse(dateString);
    
    SimpleDateFormat fmtOut = new SimpleDateFormat("dd-MM-yyyy");
    return fmtOut.format(date);
    

    Since Java 8:

    DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneOffset.UTC);
    TemporalAccessor date = fmt.parse(dateString);
    Instant time = Instant.from(date);
    
    DateTimeFormatter fmtOut = DateTimeFormatter.ofPattern("dd-MM-yyyy").withZone(ZoneOffset.UTC);
    return fmtOut.format(time);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use the Android Html.fromHtml method to parse a text like a
I´m trying to use spring android to parse an xml that looks like that
I'm trying to use this widget ( https://github.com/johannilsson/android-pulltorefresh ) in a phonegap project, but
I trying to use the new android compatibility package to include fragments into my
I am trying to use Android's LocationManager requestLocationUpdates. Everything is working until I try
I am trying to use this query upon my Android database, but it does
I am trying to use this Android: How to get a radiogroup with togglebuttons?
this is my first Android app and I'm trying to use Sockets to send
I'm trying to use the new Android 4.0 VPN framework with the Emulator. In
I am currently trying to research how to use Android with an existing java

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.