Change data appearing from integer to hh:mm:ss


I want to store an intervall. It can be months, weeks, hours, minutes and seconds. But maybe only hours, minutes and seconds. It is a regularity, repeat time, example after every 8h 34m an action runs. Not cuba action, not in my project, I only stores it’s repeat time.

So I guess I should store it in seconds, as integer. Just should display in a clear format, converted. First only the displaying the question, maybe later the edit.
Example: the integer is 26700 and in the browser sceen table shows 7h 25m.
Any idea about it? Or maybe a built-in Cuba function? :smiley:


Hi Karolina,

I’ve added example of a time interval datatype to this sample project. See, registration of the datatype in metadata.xml and usage in the Order entity.

See also documentation on creating custom datatypes.

Thank you so much! It is so much perfect!
I wanted to change the append, and I guess I should the compile too. Am I right?

One more question.
What is it good for?

private static final Pattern PATTERN = Pattern.compile("((\\d{1,})\\s*d)*\\s*((\\d{1,})\\s*h)*\\s*((\\d{1,})\\s*m)*\\s*((\\d{1,})\\s*s)*");

Just because I want to expand this to months and weeks, e.g.: 2 month 3 week, 4 hour

The regex above is for expressions like “10d 5h 20m 40s”, or “5h 20m”.

I’d suggest installing a regex tester plugin for IntelliJ like “RegexPlugin”, so you will be able to create and test regex easily. See also