0

I couldn't find any specialized answers. Here's the code:

        LocalDateTime t = LocalDateTime.now();
        System.out.println("[i][" + t.getHour() + ":" + t.getMinute()+ ":" +t.getSecond() + "] "
                + usr + " typed: " + cmd);

The output now looks like this:

[i][15:8:4] XY typed: test

What I want is to format it to make it look like this:

[i][15:08:04] XY typed: test
Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
  • @Reimeus not really, this is for a telegram bot and I'd like to keep it like this, at least for now – Coffeeking Sep 18 '17 at 13:54
  • 1
    BTW, if you are only using the time part, why not use `LocalTime` instead of `LocalDateTime`? – RealSkeptic Sep 18 '17 at 13:57
  • I'm pretty much beginner, someone helped me with creating this code. I was looking at that thread previously, marked as answer, and I couldn't find it. Thank you anyways. – Coffeeking Sep 18 '17 at 13:59
  • @RealSkeptic, good point, on the other hand there’s also sometimes a point in not throwing date-time information away prematurely. – Ole V.V. Sep 18 '17 at 14:38
  • 1
    Welcome to Stack Overflow. Tip: Most any basic date-time question has already been asked and answered here in Stack Overflow. Always search thoroughly before posting. – Basil Bourque Sep 18 '17 at 14:45

0 Answers0