customized digital clock in android

前端 未结 2 499
栀梦
栀梦 2021-01-28 08:46

hi i want to display time in my application in the format of HH:mm AM/PM. Digital clock includes seconds also. That is HH:mm:ss am/pm. how to avoid showing seconds. Is there any

相关标签:
2条回答
  • 2021-01-28 09:34
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    
    // ... 
    DateFormat format = new SimpleDateFormat("HH:mm a");
    String formatted = format.format(myDate);
    
    0 讨论(0)
  • 2021-01-28 09:36

    You have to make a clone of the file DigitalClock.java to use in your application, modify in the following manner:-

    private final static String m12 = "h:mm aa";
    private final static String m24 = "k:mm";
    

    The path of DigitalClock.java : Here

    0 讨论(0)
提交回复
热议问题