Adding a leading zero to a large string in Java

前端 未结 2 1103
盖世英雄少女心
盖世英雄少女心 2021-01-28 15:02

I am currently making an auction program in Java, I am trying to work out deadlines, however my date keeps coming out as (7/04/2013 11:22), is there a way to use String.format

2条回答
  •  [愿得一人]
    2021-01-28 15:28

    Simply use the SimpleDateFormat

    import java.text.SimpleDateFormat;
    
    Calendar timeOne = Server.getDateTime(itemArray.get(1).time)
    
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm")
    
    System.out.println(sdf.format(timeOne.getTime()))
    

提交回复
热议问题