Date、正则表达式练习
| package com.guoba.date; |
| |
| import java.text.SimpleDateFormat; |
| import java.util.Calendar; |
| import java.util.Date; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| public class DateTest { |
| public static void main(String[] args) { |
| Date date = new Date(); |
| SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| String time = simpleDateFormat.format(date); |
| System.out.println(time); |
| Calendar calendar1 = Calendar.getInstance(); |
| int year = calendar1.get(Calendar.YEAR); |
| int month = calendar1.get(Calendar.MONTH)+1; |
| int day_of_month = calendar1.get(Calendar.DAY_OF_MONTH); |
| int huor_of_day = calendar1.get(Calendar.HOUR_OF_DAY); |
| int minute = calendar1.get(Calendar.MINUTE); |
| int second = calendar1.get(Calendar.SECOND); |
| int week = calendar1.get(Calendar.DAY_OF_WEEK)-1; |
| int week1 = calendar1.get(Calendar.DAY_OF_WEEK_IN_MONTH)+1; |
| System.out.println(year+"年"+month+"月"+day_of_month+"日" |
| +huor_of_day+"点"+minute+"分"+second+"秒星期"+week+" "+week1); |
| |
| |
| } |
| } |