It's all about the answers!

Ask a question

what is the best format for an attribute that must show duration in following format HH:mm:ss ?

Luiz Almeida (23015891) | asked Oct 01 '14, 8:50 p.m.
Hi all,

I need to create an attribute that must contain a duration. I will set up this attribute by Java API, but I need to show this attribute in the following format: HH:mm:ss. What type must I use for this attribute?
I try with Timestamp, Duration and long (as Time Spent), but I can not show in this format.

Any suggestions?

2 answers

permanent link
Jonas Studer (207917) | answered Oct 02 '14, 3:14 a.m.
edited Oct 02 '14, 3:19 a.m.
Hello I don't realy get what you need.
But if you want to do it programmaticaly try this:

String myDateString = "12:34:56";
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
Date date = sdf.parse(myDateString);

Luiz Almeida commented Oct 02 '14, 7:39 a.m.

Your suggestion is to use Date format for the attribute?

Jonas Studer commented Oct 02 '14, 8:19 a.m.

Hy Luiz,

The problem I have is, I don't develop with Java in RTC.
So I might don't understand your question.

But, if I would do something in Java, with this specification.

I would use "SimpleDateFormat" to show it.
and "Date" to store it.
But as I told you, I don't know if thats possible in the RTC Java-Environment.

Because with a Date-Object, I assume, you will have more options to do something with your attribute.

SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. It allows for formatting (date -> text), parsing (text -> date), and normalization

Luiz Almeida commented Oct 02 '14, 8:26 a.m.

Ok, Jonas...I understand you now.
As Ralph said, In RTC I can not customized how I want to show this attribute in interface. This is my problem now...but thank you for your tip.

permanent link
Ralph Schoon (63.2k33646) | answered Oct 02 '14, 5:41 a.m.
Here my views on how RTC handles timestamp type attributes:

You would typically use a timestamp attribute, however the way it is displayed is controlled by the Editor Presentation you use and there are only the ones available that RTC provides.

You can use a string type, in which chase you would have to format the string as you want it. Please be aware that it will just be a string and not be handled as timestamp. E.g. you would have no date picker.

Luiz Almeida commented Oct 02 '14, 7:39 a.m.

In the Editor Presentation I have one the "Date" or "Date/Time" possibilities, this means that I can not show my attribute in "HH:mm:ss" format, right?
I am actually using a string and it works fine, but this way I can not create a query as for example: "all work itens where myattribute is greater than a x value". Am I right?

Ralph Schoon commented Oct 02 '14, 7:57 a.m.

Hi Luiz, I think you are right. I see no way to get rid of the date. There might be an option to hide the time, but not the date. I also tried the type duration and that does not provide what you desire either.

I think you are correct with queries. What would greater as in the context of just the time mean in your context?

You could create a work item.

Luiz Almeida commented Oct 02 '14, 8:44 a.m. | edited Oct 02 '14, 8:50 a.m.

I did not understand your last question...sorry, my english is not good. I will try explain what I want...
I need an attribute to persist an interval between two dates in hours, minutes and seconds. I am using Joda Time to calculate this interval and using a string attribute to persist it in format "HH:mm:ss". This works, but I can not run queries.
What I am trying now is to persist the interval in timestamp format, then I created a string attribute with a "calculate value" customization script to format the timestamp. This still didn't work, but because I don't know format the output..I am still trying.

Ralph Schoon commented Oct 02 '14, 9:00 a.m.

What do you want to achieve. That is my question, not how you think you can achieve that. 

If you just want a duration, you could use an attribute of type duration. It just shows like 3 hours. If that does nowt fit, go with the suggestions above. You can only use what RTC provides. So all the info above applies. If you want something like "later than" you have to use a timestamp attribute. RTC basically descides what query options you have based on the attribute type.

Luiz Almeida commented Oct 02 '14, 9:32 a.m.

What I need is to check if I attend an SLA. I have 6 hours to attend a task, for example. So I need to know how much time a task stays in a specific state. I am calculating the interval between begin and end of the state and recording this in a timestamp attribute. I don't know if this is the better way, maybe a duration attribute would be better. Do you have any example of how to persist duration attributes? And later is possible to present the attribute in format HH:mm:ss or only in format determined by RTC?
Thank you for the help...I am fan of your helps me so much.

Ralph Schoon commented Oct 02 '14, 10:36 a.m. | edited Oct 02 '14, 10:41 a.m.

Duration is just another work item attribute type. I have no code but as usual, you can read a duration attribute and look at its class, do the cast and/or search for duration in Java. I think it represents time in milliseconds.

You can, again, only use the available attribute presentations. Look at them and see if it is appropriate.

showing 5 of 6 show 1 more comments

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.