0

I have used Globalize.js to localize and format the date. it all works fine in different culture, but not working properly in German culture (de-DE). Code i have used to format.

Globalize.format(new Date(), "MM/yy/dd","de-DE");

it returns "10.14.01". i expecting the value as "10/14/01".

what might be the problem. is that issue in globalize? please anyone help me to come out of this headbang.

finally i found the cause of the problem. In globalize.culture.de-DE culture file

calendars: { standard: { "/": ".", firstDay: 1, .... .....

            }

some standard has been handled like above. could any help me about why this code block has been used?

2 Answers2

1

The culture de-De is German, use nl-NL instead.

Barry
  • 3,683
  • 1
  • 18
  • 25
  • thanks Barry, i have changed it. is there any solution? – SumankumarG Oct 01 '14 at 07:35
  • I see you have changed the text of your problem. You are aware that German dates ARE written with dots and not slashes? See http://www.java2s.com/Tutorial/Java/0040__Data-Type/FourdifferentdateformatsforfourcountriesUSUKGERMANYFRANCE.htm – Barry Oct 01 '14 at 07:44
  • The reference to java is just to show the date notations for different countries. – Barry Oct 01 '14 at 07:51
  • I think the OP wants to use a specific format string, instead of using a format defined by a locale. The locale parameter is actually irrelevant in this case. – Jukka K. Korpela Oct 01 '14 at 08:20
0

It seems that you are using the old version of Globalize.js, which works rather well but isn’t developed any more, and it can be difficult to find documentation of it except in my book.

The rules for the format argument are somewhat obscure, but when a format like "MM/yy/dd" does not work, put any characters that should appear “as is” inside Ascii apostrophes, in this case

"MM'/'yy'/'dd"

Some punctuation characters can be used inside the format string without such quoting, but when in doubt, quote.

Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390