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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:15:02+00:00 2026-06-02T02:15:02+00:00

If this function is passed an invalid date and an IllegalFieldValueExcption is thrown I

  • 0

If this function is passed an invalid date and an IllegalFieldValueExcption is thrown I would like to return a default date of 0001-01-01. But when the code below is ran the date that is created in defaultDate is 0001-01-02, which is wrong. Does anyone see anything i’m doing wrong?

public Date unmarshal(String string) {    
    DateTimeFormatter fmt = new DateTimeFormatter(null, DateTimeFormat.forPattern("yyyy-MM-dd").getParser());
    Date defaultDate = DateTime.parse("0001-01-01", fmt).toDate();

    try {
        return formatter.parseDateTime(string).toDate();
    }
    catch (IllegalFieldValueException e) {
        return defaultDate;
    }
}

EDIT:

I updated the first two lines with these and it is working perfect now, thanks!

Chronology chrono = GJChronology.getInstance();
Date defaultDate = new DateTime(0001, 01, 01, 10, 0, 0, 0, chrono).toDate();
  • 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-02T02:15:04+00:00Added an answer on June 2, 2026 at 2:15 am

    The issue you have is because the default chronology in Joda-Time is ISO. This calendar system is the same as that used by business in the majority of the world today. The ISO system is unsuitable for historical work before 1583 as it applies the leap year rules from today back in time (it is a proleptic calendar).

    So you shoudn’t use a defaultDate before 1583 with ISO Chronology. If you need to use such Date, you have to use a different chronology in Joda-Time.

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

Sidebar

Related Questions

... // result is a JSON data passed to this function from outside var
This function gives me the following error: SyntaxError: Invalid character '\u8203' All looks good
I'm getting an error Warning: implode() [function.implode]: Invalid arguments passed in /home/social/public_html/form_test.php on line
The following PHP, when passed this image , writes 0 bytes to $cache (but
Can somebody help me with this: this is my code: //js var TestPlugin={ test:function(name,successCallback,failureCallback){
To my knowledge the standard strcmp function looks something like this: int strcmp(const char*
This function declaration gives me errors: ostream& operator<<(ostream& os, hand& obj); The errors are:
This function is written in ActionScirpt. What kind of decryption this is? Is there
This function of mine keeps on failing an autograder, I am trying to figure
This function creates & stores a cookie, and here it stores the name of

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.