Ad
  • Custom User Avatar

    very good solution, but you could also have used your formatter DTF for the parsing, instead splitting on the PIPE:
    LocalTime.parse(s, DTF).toSecondOfDay

    sorry, I didn't saw that the inputs have randomly 1 or two numbers, so the Formatter can't be used for Parsing; you would need a FORMATTER and a PARSER, where the PARSER will use optional section:

    private static final DateTimeFormatter PARSER = DateTimeFormatter.ofPattern("H[H]|m[m]|s[s]");
    private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("HH|mm|ss");
    
  • Default User Avatar

    this was an inspirational solution to look at... so clean and so great! both the logic and formatting - I think I even like splitting the ternary over three lines. well done

  • Custom User Avatar

    Awesome solution. I planned on using DateTimeFormatter.ofPattern() too, but I've never really used DateTime related stuff, so I couldn't figure out how to calcualte everything with that type.

  • Default User Avatar

    Pretty much what I wanted to do, but couldn't find anything about how to use existing libs to format HH:MM:SS. Only found old arse posts about Date and Calender.
    Groovy solutions there, very nice.

  • Custom User Avatar

    rename howmanyBees > howManyBees