Java Timestamp - How can I create a Timestamp with the date 23/09/2007?

后端 未结 8 1814

How can I create a Timestamp with the date 23/09/2007?

8条回答
  •  北海茫月
    2020-11-28 21:27

    What do you mean timestamp? If you mean milliseconds since the Unix epoch:

    GregorianCalendar cal = new GregorianCalendar(2007, 9 - 1, 23);
    long millis = cal.getTimeInMillis();
    

    If you want an actual java.sql.Timestamp object:

    Timestamp ts = new Timestamp(millis);
    

提交回复
热议问题