Five Stars

TalendParseDate error

Hi All ,

The below command is not working properly with YYYY and the same is working good with yyyy

 

TalendDate.parseDate("MMM dd YYYY",TalendDate.getDate("MMM dd yyyy")

 

TalendDate.parseDate("MMM dd yyyy",TalendDate.getDate("MMM dd yyyy")

 

Can someone suggest the purpose of YYYY and when can i use and why it is giving invalid result.

 

Thanks,

Bharath

8 REPLIES
Four Stars

Re: TalendParseDate error

Hi Bharat,

 

since java is case sensitive so YYYY does not work for it.

The date format always has dd MM yyyy .

Let me know more about your requirement.

 

Regards,

Neha

 

 

Neha
Tags (3)
Five Stars

Re: TalendParseDate error

hi neha,

 

Here there is no requirement .both commands are working properly, but

YYYY is not giving correct result and yyyy is giving correct result, 

may i know the reason why YYYY is not throwing error and giving junk value or any significance for YYYY

Four Stars

Re: TalendParseDate error

Hi,

 

Well I have faced error saying : Invalid character near 'Y' , whenever I have used YYYY by mistake in my date formats instead of yyyy.

Like for exmaple, M is always capital and d is always small in a date format ,similarly y is always small. It will simply not work with capital Y because its something in-built in java, as far as my knowledge is concerned.

I wish I could help you more in this by seeing any screen-shot and figure out the exact issue. let me know if I can solve more.

 

Thanks,

Neha

Neha
Moderator

Re: TalendParseDate error

Hi,

"yyyy" stands for Year in Java Date. You can get date pattern from schema setting.

Please have a look at my screenshot.

1.png

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: TalendParseDate error

Hi ,

 

The command i posted, it  is not throwing any parsing error and it is working fine and giving  improper result.

 

Thanks,

Bharath

Five Stars

Re: TalendParseDate error

yyyy is stands for year and wat about YYYY and why it is not throwing error. 

YYYY is giving result which is not correct result and the result for YYYY is on what basis caluclated.

Ten Stars

Re: TalendParseDate error

https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

 

According to the Java docs, 'Y' represents "Week Year" which is slightly different from 'y'.

 

This stackoverflow article goes into more detail:
https://stackoverflow.com/questions/8686331/y-returns-2012-while-y-returns-2011-in-simpledateformat

Moderator

Re: TalendParseDate error

Hello,

Thanks for sharing the related docs with us.

 

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.