1 2 3 4 5 6 |
nowDate = new Date(); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); String nowDateString = dateFormat.format(nowDate); int nowDay = Integer.parseInt(nowDateString.substring(0, 2)); int nowMonth = Integer.parseInt(nowDateString.substring(3, 5)); int nowYear = Integer.parseInt(nowDateString.substring(6, 10)); |
- Date() + SimpleDateFormat()
123Date myDate = new Date();DateFormat myDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");System.out.println(myDateFormat.format(myDate)); - Calender() + SimpleDateFormat()
123DateFormat myDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");Calendar myCal = Calendar.getInstance();System.out.println(myDateFormat.format(myCal.getTime()));