Get Date/Time Pattern in ICU4J - icu

I have a requirement where I need the pattern ICU uses to format the given date/time.
For example: If I have something like DateFormat.getDateInstance(DateFormat.SHORT, en_US).format(currentDate) gives me 5/3/2015, then I need an API which can tell me that the pattern ICU4J internally using is d/M/yyyy.

I did figure out a solution, all you need to do is convert the DateFormat into a SimpleDateFormat and call toPattern().
((SimpleDateFormat)DateFormat.getDateInstance(DateFormat.SHORT, en_US)).toPattern() returns d/M/y which is what I almost needed.

Related

String Foramting vb.net

i want to display date value like '2020/03/30' as '20200330'
i tried this code
Date.Now.Year & Date.Now.Month & Date.Now.day
but this returns 2020330
how can this return 20200330 ??
You are concatenating numbers, which get implicitly converted to strings.
You could check out Custom date and time format strings.
In your case, this might do just fine: Date.Now.ToString("yyyyMMdd")
By the way, as #jmcilhinney already commented to your question, you could easily find such basic information by using your favorite search engine on the internet...

Time Data From Nest API In Correct Format?

I have noticed that the date and time fields being returned to me from the Nest API are not matching the format that the API documentation lists.
For my thermostat, I am getting the following for last_connection:
"last_connection": "2014-10-27T20:22:12.165Z"
But the API documentation lists it should be formatted as:
"last_connection": "2014-10-27T20:22:12+06:00"
Why is the Nest API returning milliseconds to me and why am I getting the character "Z" instead of the actual timezone offset that the date/time is coming from?
It looks like the example is incorrect with respect to the actual implementation. If you look at the API Reference you will see the time data is all in ISO 8601, which support both string types.
This also means you should likely use a library to support ISO 8601, rather than manually parsing the string if possible.

Dart DateTime.parse() string date return by ServiceStack

I have date string return by ServiceStack : 2013-08-25T12:06:32.8770000 but error when convert to date of Dart
DateTime.parse(mapAccount[Account.RECCREATED]);
it ok when call
DateTime.parse((mapAccount[Account.RECCREATED] as String).substring(0, 26));
Is there anyway to fix it. Thanks you.
Looks like the string don't match the internally used regular expression:
r'^([+-]?\d?\d\d\d\d)-?(\d\d)-?(\d\d)(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(.\d{1,6})?)?)? ?([zZ])?)?$'
But the regular expression doesn't support more that 6 digits for the milliseconds (and microseconds) part, but you supply 7 digits.
The documentation does not state which formats are supported, but gives some examples. They only state that they support a subset of ISO 8601.
Looks like your solution is the only one a the moment.
Not sure if this should be treaded as a bug, but if you think it is a bug, create a bug report here.
See the docs about DateTime.parse for more details. Looks like the problems with the parse function is already in the bug tracker.

DateTimeFormat with Timezone and no colon

I am using Talend Open Studio to fetch info from a DB to an XML file and then using XSLT on that.
There is a date field that comes into the XML as: 2013-02-13T16:49:51.733+0230, when I supply a Date Pattern: "yyyy-MM-dd'T'HH:mm:ss.SSSZ".
I believe SimpleDateFormat has this limitation of not able to deal with colon.
I need the colon in between the timezone value: +02:30. How can I achieve that? Is there a different Pattern String that I can use? If not, can I do it in my XSL Transform?
Function format-dateTime() looks for current-dateTime() format which needs colon between time zone HH:MM, in your case it is missing (0230). You should use another method to put colon between them:
let $x:= "2013-02-13T16:49:51.733+0230"
return concat(substring-before($x,'+'),'+',substring(substring-after($x,'+'),1,2),':',substring(substring-after($x,'+'),3,2))
output:
2013-02-13T16:49:51.733+02:30

vxml element in ssml

i m just stuck with a vxml element in an ssml file in tropo. tropo does not recognize
interpret="time" and i have to put interpret="vxml:time".
But I need to also define the format attribute format:"hms12". so i write this:
<say-as interpret-as="vxml:time" format="hms12">243P</say-as> </s>
but it keeps pronouncing it like three integers.
i searched everywhere for the right syntax but couldn't find something.
I believe that is the default format for Tropo. Leave out the format attribute and make format your value as "0243p" for 2:43 PM, instead of "243P" as you have it. If you do not have your value in the exact format from the source of the data I would just convert it to this format rather than trying to force Tropo to conform to its format.

Resources