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

How to compare two ints in java?

Question:
The user is asked to enter two positive integers. The program prints them in ascending order or states that they are equal.

Code:
import java.util.Scanner;
 
public class CompareInts {
  public static void main(String[] args) {
 
    Scanner sc = new Scanner(System.in);
 
    System.out.print("Enter 1st number: ");
    int i1 = sc.nextInt();
 
    System.out.print("Enter 2nd number: ");
    int i2 = sc.nextInt();
 
    if (i1 == i2) {
      System.out.println("Equal");
    } else if (i1 < i2) {
      System.out.println(i1 + " " + i2);
    } else {
      System.out.println(i2 + " " + i1);
    }
 
  }
} 
 

Output:
$ java CompareInts
Enter 1st number: 3
Enter 2nd number: 1
1 3