Calendar Constructor Java toString

前端 未结 5 1402
天命终不由人
天命终不由人 2021-01-21 01:30

What I\'m trying to do is pass a date into the Calendar so that it will format the date ready for use with another constructor. So that i can make use of it later using the func

5条回答
  •  臣服心动
    2021-01-21 02:17

    If you want to print the date represented by a calendar instance, as a string, you should use SimpleDateFormatter to format the date in the required format, as follows:

    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyy");
    System.out.println(sdf.format(DateD.getTime());
    

提交回复
热议问题