Yet another newbie time problem

I apologize in advance. It seems there is tons of date time conversion information out there, but I cant figure this simple issue out.

My log files always produce time strings like: 2022-11-06T07:06:00.990574

How do I get more human readable dates and times?
I have been through the date/time formatting documentation and cannot locate a simple solution to formatting time in a rule.

The toString modifiers dont do anything and dont produce any errors either. Why doesnt the following statement produce a simple hour and minute result?

logInfo(“Update States”,“Running Update house at: {}”,now.toLocalDateTime.toString(“hh:mm”))

Instead of 6:00, I get 2022-11-06T07:06:00.990574.

Geez!

First of all: wrong category, Tutorials & Examples is for solutions, not questions.

You’ll have to use a formatter to change the format, so please try

logInfo("Update States","Running Update house at: {}",String::format("%1$H:M",now))

Please be aware that code should always be marked as code, otherwise the forum software might change some characters (like “ vs. ")

Thanks,

That code gets me: Running Update house at: 71AE4F50:M

Ah, sorry, missed the t…

logInfo("Update States","Running Update house at: {}",String::format("%1$TH:%1$TM",now))

Thanks,

I am a programmer (not java). I feel pretty bad having so much trouble formatting a simple time object.

Thanks again.

Please don’t feel ashamed, me either…

Formatter (Java SE 11 & JDK 11 ) has the full docs on string formatting.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.