Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

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?



0 votes



2 answers

Permanent link
Hello I don't realy get what you need.
But if you want to do it programmaticaly try this:

http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

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

1 vote

Comments

Jonas,
Your suggestion is to use Date format for the attribute?

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

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
Here my views on how RTC handles timestamp type attributes: https://rsjazz.wordpress.com/2014/07/22/manage-scheduled-absences-using-the-plainjava-client-libraries/

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.

1 vote

Comments

Ralph,
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?

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.

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

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.

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 blog...it helps me so much.

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

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,941

Question asked: Oct 01 '14, 8:50 p.m.

Question was seen: 4,115 times

Last updated: Oct 02 '14, 10:41 a.m.

Confirmation Cancel Confirm