-1

特定の日付の後に st、nd、rd、および th を出力できる日付 API の特定の形式はありますか。12 月 26 日を 12 月 26 日とします。

また、午前 10 時 30 分などの時間の特定の形式も、形式はまったく同じである必要があります。

これを解決するには、組み込みのパターンのみが必要です。

以下のシナリオのコードを書きましたが、目的の出力が得られません

    //Checking date format
    String pattern = "EEE, MMM.dd";
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
    String date = simpleDateFormat.format(new Date());
    System.out.println(date);

    //checking time format

    DateFormat dateFormat2 = new SimpleDateFormat("hh.mm aa.");
    String dateString2 = dateFormat2.format(new Date()).toString();
    System.out.println(dateString2);
4

3 に答える 3