java代码实现如下
/**
|
*
|
*/
|
public static String "yyyy-MM-dd" ;
|
|
/**
|
*
|
*/
|
public static String "yyyy-MM-dd ;
|
|
/**
|
*
|
*/
|
public static String "yyyy-MM-dd ;
|
|
/**
|
*
|
*/
|
public static String "yyyy年MM月dd" ;
|
|
/**
|
*
|
*/
|
public static String "yyyy年MM月dd日 ;
|
|
/**
|
*
|
*/
|
public static String "yyyy年MM月dd日 ;
|
/**
|
*
|
*/
|
public static String
|
SimpleDateFormat new SimpleDateFormat(FORMAT_FULL);
|
Calendar
|
return df.format(calendar.getTime());
|
}
|
/**
|
*
|
*
|
*
|
*/
|
public static String
|
return format(date).substring( 0 , 4 );
|
}
|
/**
|
*
|
*
|
*
|
*
|
*
|
*/
|
public static int getMonth(Date
|
calendar
|
calendar.setTime(date);
|
return calendar.get(Calendar.MONTH) 1 ;
|
}
|
/**
|
*
|
*
|
*
|
*
|
*
|
*/
|
public static int getDay(Date
|
calendar
|
calendar.setTime(date);
|
return calendar.get(Calendar.DAY_OF_MONTH);
|
}
|
/**
|
*
|
*
|
*
|
*
|
*
|
*/
|
public static int getHour(Date
|
calendar
|
calendar.setTime(date);
|
return calendar.get(Calendar.HOUR_OF_DAY);
|
}
|
/**
|
*
|
*
|
*
|
*
|
*
|
*/
|
public static int getMinute(Date
|
calendar
|
calendar.setTime(date);
|
return calendar.get(Calendar.MINUTE);
|
}
|
/**
|
*
|
*
|
*
|
*
|
*
|
*/
|
public static int getSecond(Date
|
calendar
|
calendar.setTime(date);
|
return calendar.get(Calendar.SECOND);
|
}
|
/**
|
*
|
*
|
*
|
*
|
*
|
*/
|
public static long getMillis(Date
|
calendar
|
calendar.setTime(date);
|
return calendar.getTimeInMillis();
|
}
|