Creating java date object from year,month,day

前端 未结 6 1053
长情又很酷
长情又很酷 2020-11-27 14:50
int day = Integer.parseInt(request.getParameter(\"day\"));  // 25
int month = Integer.parseInt(request.getParameter(\"month\")); // 12
int year = Integer.parseInt(re         


        
6条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 15:25

    Make your life easy when working with dates, timestamps and durations. Use HalDateTime from

    http://sourceforge.net/projects/haldatetime/?source=directory

    For example you can just use it to parse your input like this:

    HalDateTime mydate = HalDateTime.valueOf( "25.12.1988" );
    System.out.println( mydate );   // will print in ISO format: 1988-12-25
    

    You can also specify patterns for parsing and printing.

提交回复
热议问题