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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:10:29+00:00 2026-05-12T08:10:29+00:00

I have made a generic parser for parsing ascii files. When I want to

  • 0

I have made a generic parser for parsing ascii files.
When I want to parse dates, I use ParseExact function in DateTime object to parse, but I get problems with the year.

The text to parse is i.e. “090812” with the parseExact string “yyMMdd”.

I’m hoping to get a DateTime object saying “12/8-2009”, but I get “12/8-1909”.
I know, that I could make an ugly solution by parsing it afterwards, and thereby modifying the year..

Anyone know of a smart way to solve this ??

Thanks in advance..

Søren

  • 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-12T08:10:30+00:00Added an answer on May 12, 2026 at 8:10 am

    Theoretically elegant way of doing this: change the TwoDigitYearMax property of the Calendar used by the DateTimeFormatInfo you’re using to parse the text. For instance:

    CultureInfo current = CultureInfo.CurrentCulture;
    DateTimeFormatInfo dtfi = (DateTimeFormatInfo) current.DateTimeFormat.Clone();
    // I'm not *sure* whether this is necessary
    dtfi.Calendar = (Calendar) dtfi.Calendar.Clone();
    dtfi.Calendar.TwoDigitYearMax = 1910;
    

    Then use dtfi in your call to DateTime.ParseExact.

    Practical way of doing this: add “20” to the start of your input, and parse with “yyyyMMdd”.

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

Sidebar

Related Questions

I have made a generic PHP script to use for an AJAX call. I
I have made a generic function to show jQuery dialogs in my app. this
I have made a generic Observer interface and an Observable class, but can't compile
I have made a java project and want to deliver it to a client
I have made a generic handler (.ashx) to fetch some database values using jquery
I have made one application which can parse the given xml file independent of
I am making a generic text validation function with jQuery. I made the function
i have to do a generic double linked list, and i made it in
I made a generic app, and from that app, I use different images to
I have made an application (for my self) for feeds reading, using SyndicationFeed ,

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.