DateTimeFormat with Timezone and no colon - string

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

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...

Using tab as delimiter in tFileInputDelimited component in Talend Open Studio

I have written an ETL in Talend Open Studio that loads a CSV/TSV file in a database. To do so, I want to provide the delimiter in tFileInputDelimited component using dynamic context load from a text file. I have specified it in the context file as fieldDelimiter="\t" and in the tFileInputDelimited component as shown in the screenshot. But, it doesn't work as a delimiter. I have also tried using fieldDelimiter="\\t" or fieldDelimiter="\u0009" (unicode character for tab).
What should I provide in the context file so that the delimiter is a tab character and not "\t" string as is happening in this case?
I notice a difference in the context variable names. In the screen shot you have mentioned (String)context.get("fileDelimiter"). But in the text you are saying "I have specified it in the context file as fieldDelimiter="\t" ".
just keeping the context as follows in the .properties file should work
fieldDelimiter=\t
Also use context.fieldDelimiter instead of (String)context.get("fileDelimiter").
In your context file, just put fileDelimiter = \t
(Without quotes)
And then access the variable in field delimiter. Talend will automatically handle it as string.
Hope this works.
There is no function (String)context.get("key") that I know of. If you have set the separator as a String element in the Context, just access it directly. Now there will be an empty String set as the field separator I suppose.
So if your field is called fileDelimiter simply put context.fileDelimiter into the Field Separator.
As pointed out by others, you should use context.ParamName syntax, the benefit of this method is syntax checking at compile time which eliminates the risk of typos in your variable names.
This parameter must be declared in your job (contexts tab) in order for Talend to recognize it. You can either create it as a built-in or import it if it's in the repository.

SSRS - How to get a part of a string

I have a parameter called Analyst group in this format :
[Dimension].[Analyst Group].&[Nl.Workplace.Foundation]
I want to pass this parameter to another report, to filter data. Its a multi value parameter. But the other report only accepts it in this format : [KanBan].[Analyst Group].&[Nl.Workplace.Foundation]
So im trying to isolate the "Nl.Workplace.Foundation", so i can do the following thing in the Go To Report parameter expression :="[KanBan].[Analyst Group].&["& --Isolated analyst group-- &"]" to create the desired format.
So what i need is to extract the part between .&[ and ]
But i really have no idea how to isolate that part of the string.
Found a solution! If i just use the Parameter.label instead of Parameter.value it automatically does what i want!
A different solution has been found, but I will still answer the initial question. It could help.
So what i need is to extract the part between .&[ and ]
You could use a regex.
This may not be the fastest way but it can handle most of the situations.
So let's assume you have a string containing:
[Dimension].[Analyst Group].&[Nl.Workplace.Foundation]
And you want to get the following string:
Nl.Workplace.Foundation
Just use the following expression:
=System.Text.RegularExpressions.Regex.Match("[Dimension].[Analyst Group].&[Nl.Workplace.Foundation]", "\.&\[(?<NWF>[^]]+)\]").Groups("NWF").Value
In the expression, replace the input string with your dynamic values, like for example:
=System.Text.RegularExpressions.Regex.Match(Fields!Dimension.Value & "." & Fields!AnalystGroup.Value, "\.&\[(?<NWF>[^]]+)\]").Groups("NWF").Value
I'm keeping the formula as simple as possible so that you can easily adapt it, with, say, handling the case where an input string will not have a match (with the above query it will return #Error).
You could do this by adding an IIF() or better, use a custom function that you can reuse in several places and will reduce the length of your expression.

Get Date/Time Pattern in ICU4J

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.

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