Write a java program to return a time in hh:mm:ss format?

Question:
How to write a java program to return a time in hh:mm:ss format?

Answer:
Format formatter = new SimpleDateFormat( "hh:mm:ss" );

Code:
import java.text.Format ;
import java.text.SimpleDateFormat ;
import java.util.Date ;
 
public class PrintTime {
  public static void main( String[] args ) {
    Format formatter = new SimpleDateFormat( "hh:mm:ss" );
    System.out.println( formatter.format( new Date() ) );
    }
}

Output:
$ java PrintTime
09:10:12