cancel
Showing results for 
Search instead for 
Did you mean: 

Number of the day in the year

former_member223432
Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member184681
Active Contributor
0 Kudos

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

former_member223432
Participant
0 Kudos

Hi Grzeg,

Thanks for your reply..problem solved...points given..thanks much

Answers (2)

Answers (2)

anupam_ghosh2
Active Contributor
0 Kudos

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

former_member223432
Participant
0 Kudos

Hi Anupam,

Thanks for your reply.

I need to concatenate : "number of the day in the year" not the current date...

For ex: feb 2 == 33rd day of the year..

so i would be concatinating this with HHMM..i.e: 1205033 should be my ouput...

Regards

former_member184681
Active Contributor
0 Kudos

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

former_member223432
Participant
0 Kudos

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.

PriyankaAnagani
Active Contributor
0 Kudos

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