Java – Difference Between ‘kk’ and ‘HH’+1 in ISO-8601

date formatjava

In the ISO-8601 there are multiple hour formats, one of them is "kk" for hours 1-24.

What is the purpose of this? Are there countries that offset their time? Is it for military usages?

The wikipedia article didn't clarify the exact nature between HH and kk. The main source of my concern is the behaviour of the formats in SimpleDataFormatter.

Edit:
The direct part from the SimpleDateFormat that I'm referring to is this:

H Hour in day (0-23) Number 0
k Hour in day (1-24) Number 24

In usage…

HH:mm:ss  // 00:00:00
kk:mm:ss  // 01:00:00

Best Answer

Direct answer to your question, there is no difference. The point is you do not need to do the +1 computation by using kk. My source can be found at: http://www-01.ibm.com/support/knowledgecenter/SSKM8N_8.0.0/com.ibm.etools.mft.doc/ak05616_.htm?lang=pt

Here you find this description:

HH hour of day in 24 hour form (00-23) kk hour of day in 24 hour form (01-24)

Now, regarding HH+1 = kk. Example: HH: 00 in kk is 01. You can do this for each of the values.

As for the usage, it is for i18n purposes or different usages as you already mentioned. In different parts of world, different notations are used. But normally, you would only use kk in situations in which you have business hours which goes beyond or after 24 hours. For example, TV stations.