android.text.format.DateFormat “HH” is not recognized like with java.text.SimpleDateFormat

后端 未结 5 1127
挽巷
挽巷 2020-12-15 06:35

When I use the \"HH\" flag in android.text.format.DateFormat, it is interpreted as a literal \"HH\". But when I use java.text.SimpleDateFormat it

5条回答
  •  不知归路
    2020-12-15 07:30

    I have never programmed for Android. I googled the DateFormat javadoc and saw there the following examples:

    Examples for April 6, 1970 at 3:23am:
    "MM/dd/yy h:mmaa" -> "04/06/70 3:23am"
    "MMM dd, yyyy h:mmaa" -> "Apr 6, 1970 3:23am"
    "MMMM dd, yyyy h:mmaa" -> "April 6, 1970 3:23am"
    "E, MMMM dd, yyyy h:mmaa" -> "Mon, April 6, 1970 3:23am&
    "EEEE, MMMM dd, yyyy h:mmaa" -> "Monday, April 6, 1970 3:23am"
    "'Noteworthy day: 'M/d/yy" -> "Noteworthy day: 4/6/70"
    

    The "hour" is marked using small letter h in opposite to SimpleDateFormat where capital letter is used for this purpose.

提交回复
热议问题