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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:15:05+00:00 2026-06-10T10:15:05+00:00

I am parsing multiple String objects containing date in format of mm/dd/yyyy into Date

  • 0

I am parsing multiple String objects containing date in format of mm/dd/yyyy into Date objects using SimpleDateFormatter

Problem I am facing is that, some String contain complete date means it is mm/dd/yyyy while some Strings do not contain year and comes in this format mm/dd

I am using this format to parse dates MM/dd/yyyy but everytime I get a String with only month and day, I get parsing exception.

I want to know, is there any way by which if a year field is missing then I can use something like 0000 or I need to tackle it into exception body only?

  • 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-10T10:15:06+00:00Added an answer on June 10, 2026 at 10:15 am

    as far as i know you can create an instance of SimpleDateFormat that does not “need” an year.
    So just use an try-catch-Block

     try{
        //try formatting with simpledate instance with year
     }catch (Exception thrown when no year){
        try{
           //try formatting with simple date instace without year
        } catch (Exception e)
           //something went wrong both did not accept it
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to combine multiple JSON objects into a single one in PHP. I'm
I wish to construct a date format that will optionally have a time argument.
I am trying to parse a string into a date in the constructor of
I'm parsing XML to get multiple markers directly from the database, so used the
Parsing the string message seems bad. Or was this exception not meant to be
Im parsing the source of a website and Im using this regex: /page\.php\?id\=([0-9]*)\\>(.*)\<\/a\>\<\/span\>/.match(self.agent.page.content) self.agent.page.content
Not parsing the parameters in the beginning but parse the input string read from
I have a problem parsing a XML file which contains special characters like ,
I'm working with an xml document in C# that has multiple (100+) points of
I have multiple client databases that I need to hit on the fly and

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.