Transform a time into seconds

One Star

Transform a time into seconds

Hi!
I am trying in the tMap to transform a time that I get out from a data source in string like this "12:13:55" to seconds (43200 + 720 + 55 = 43975) in this case.
How can I do that with the expressions given to me in the tMap Expressions?
Thanks
Joakim
One Star

Re: Transform a time into seconds

Hi,
Create a routine :-
public static String CalculateTotalSeconds(String timein) {
String[] date_string = timein.split(":");
int hours = Integer.parseInt(date_string);
int mins = Integer.parseInt(date_string);
int seconds = Integer.parseInt(date_string);

int totalsec = (hours * 3600)+ (mins* 60) + seconds;

return "" + totalsec;
}
Call from tmap :-
Date_Converter.CalculateTotalSeconds(variable);
Returns a string with total seconds.
HTH
One Star

Re: Transform a time into seconds

tnewman: Thanks for the example. I just don´t know how to create a routine, I am in the Navigator mode of the Repository but I dont understand how to create it.
// Joakim
One Star

Re: Transform a time into seconds

I dont have the "code" section in my Repository that is shown on examples I have seen... How do I get that visible?
One Star

Re: Transform a time into seconds

Hi,
I am using TIS and I see the Code branch in the standard view. I have looked around the various menus and cannot see anywhere we you can include/exclude from the repo view.
I am not sure if TOS is different.
Sorry I can't be much more help - maybe someone else can answer.
One Star

Re: Transform a time into seconds

It's in TOS too, at least for java projects.