Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Chinese Calender Date is not able to parse

 
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am getting the Chinese Calender date I and reading that String and parsing using java code.



01010229 is a valid Chinse date but I am getting parsing Exception here.

May be I am doing something wrong here.

Can some one help me in reading Chinese Calender dates in Java or Gregarian Calender format.

Thanks in advance.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can get a chinese calendar with

Normally you don't have to specify the Locale as getInstance() will return the correct instance depending on your locale.

It looks like the year is incorrect in your date. Is 0101 really a valid year? I think Date instances start from 1970. So that might be the trouble there...
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java 6 doesn't contain a Chinese calendar: if you look at the source code you'll see Japanese and Thai are the only ones other than Gregorian. I haven't checked Java 7, so I don't know if it's added any more.

In terms of the Gregorian calendar, I'd think the problem would be having 29 Feb in a non-leap-year.
 
Amruth Puppala
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Carlo Moore for the response.
As per my knowledge I guess Locale will be used for displaying different locale dispays like Chines language, Thai language etc.


Thanks Matthew Brown for the reponse. Yes becoz of the leap year it is getting error.
Infact Chinse Year+1911 is equal to Our standard date.
so 01010229 is equal to 2012 Feb 29. But Whatever I validated is considered as 0101 year means 101 year which is not a Leap year.

My question is how do we handle Chinese dates in Java , as per me now I am adding 1911 year to Chines year and continuing from there.

Any help appreciated.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic