on 01-23-2012 10:51 AM
Hi,
I have a requirement to add the number of the day in the year to the message and concatenate with HHMM as shown below
like this :1205001...12:HH,05:MM; 001(1st day of the year)
ex2: 0204365...02:HH;04:MM;DDD:365(last day of the year)
ex3: 0209236..02:HH;09:MM;DDD:236:(236th day of the year)...
How can i achieve this? any standard functionality?
please advise.
Regads
Hi,
Here is the code that is ready to be used, assuming that you need current (processing) time & date:
Calendar calendar = Calendar.getInstance();
int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR);
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
String result = Integer.toString(dayOfYear) + Integer.toString(hour) + Integer.toString(minute);
return result;
Hope you find it useful,
Greg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
Is it the current system date you wanna concatenate? Anyways this can be achieved by message mapping using standard functions
input--------------------------------------------------------------------\
concat()--------> target field
currentdate()--->Transformdate(yyyy/MM/dd,hh:mm:DDD)----------------------/
If its not system date then you can input any field like "2012/01/02" or change the format of input date transformdate (the first field).
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use a simple User-Defined Function for this purpose. Find an example of Java code to get number of day of year (as a basis for your development )here:
http://www.easywayserver.com/blog/java-calendar-how-to-find-day-of-year/
Hope this helps,
Greg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi greg,
Thanks for your reply...
I just used the given code in PI mapping and i am getting the below error..any idea?
Function calculate1, Line 2:
illegal start of expression
public class DayOfYear {
^
Function calculate1, Line 2:
';' expected
public class DayOfYear {
^
Function addSpaces, Line 1:
illegal start of expression
public String addSpaces(String var1, Container container) throws StreamTransformationException{
I am not familair with the JAVA coding language..kindly suggest me for this error..
Your help would really eb appreciated.
Hi,
>>I just used the given code in PI mapping and i am getting the below error..any idea?
Function calculate1, Line 2:
illegal start of expression
public class DayOfYear {
^
You need not write class declaration in your UDF. You just need to copy the code written in the main method and use it in your UDF.
Regards,
Priyanka
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.