Languages
[Edit]
EN

Java - format ZonedDateTime to get only hour and minutes in format HH:mm

1 points
Created by:
Hayley-Mooney
437

Quick solution:

import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

public class Example {

    public static void main(String[] args) {

        DateTimeFormatter fmt = DateTimeFormatter.ofPattern("HH:mm");
        ZonedDateTime zonedDateTime = ZonedDateTime.now();

        String format = fmt.format(zonedDateTime);
        System.out.println(format); // 22:16
    }
}

 

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join