1、获取当前年月日...信息的方法
1 public class CommonDate { 2 3 public final String year = String.valueOf(Calendar.getInstance().get(Calendar.YEAR)); 4 public final String month = String.valueOf(Calendar.getInstance().get(Calendar.MONTH)+1); 5 public final String day = String.valueOf(Calendar.getInstance().get(Calendar.DAY_OF_MONTH)); 6 public final String hour_24 = String.valueOf(Calendar.getInstance().get(Calendar.HOUR_OF_DAY)); 7 public final String hour_12 = String.valueOf(Calendar.getInstance().get(Calendar.HOUR)); 8 public final String minute = String.valueOf(Calendar.getInstance().get(Calendar.MINUTE)); 9 public final String second = String.valueOf(Calendar.getInstance().get(Calendar.SECOND)); 10 public final String week_of_year = String.valueOf(Calendar.getInstance().get(Calendar.WEEK_OF_YEAR)); 11 public final String week_of_month = String.valueOf(Calendar.getInstance().get(Calendar.WEEK_OF_MONTH)); 12 public final String day_of_year = String.valueOf(Calendar.getInstance().get(Calendar.DAY_OF_YEAR)); 13 public final String day_of_month = String.valueOf(Calendar.getInstance().get(Calendar.DAY_OF_MONTH)); 14 public final String day_of_week = String.valueOf(Calendar.getInstance().get(Calendar.DAY_OF_WEEK)); 15 16 17 18 /** 19 * 获取当前时间 20 * @return 当前时间,24小时yyyy-MM-dd HH:mm:ss格式 21 */ 22 public String getTime24(){ 23 Date date = new Date(); 24 SimpleDateFormat timeStamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 25 String time = timeStamp.format(date); 26 return time; 27 }
2、获取请求的ip地址
3、由于数据库中是time格式,所以要获取时分秒的格式
4、Spring.xml文件为对象传list格式数据
原文地址:https://www.cnblogs.com/x54256/p/8733363.html
时间: 2024-10-08 00:21:17