首页javalegacy_date_formatJava Data Type - 如何日期12am存储为24,kk:mm:ss而不是HH:mm:ss

Java Data Type - 如何日期12am存储为24,kk:mm:ss而不是HH:mm:ss

我们想知道如何日期12am存储为24,kk:mm:ss而不是HH:mm:ss。
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class Main {
  public static void main(String[] args) throws Exception {
    SimpleDateFormat broken = new SimpleDateFormat("kk:mm:ss");
    broken.setTimeZone(TimeZone.getTimeZone("Etc/UTC"));
    SimpleDateFormat working = new SimpleDateFormat("HH:mm:ss");
    working.setTimeZone(TimeZone.getTimeZone("Etc/UTC"));

    Date epoch = new Date(0);

    System.out.println(broken.format(epoch));
    System.out.println(working.format(epoch));
  }
}