Java将⽇期格式化成数组年⽉⽇的格式
/**
* 格式化⽇期为年⽉⽇
*
* @param date
* @return [年⽉⽇]
*/
protected static String[]formatDate(Date date){
String[] s =new String[3];
Calendar c = Instance();
if(date == null)
date =new Date();
c.setTime(date);
s[0]= String.(Calendar.YEAR));
s[1]= String.format("%02d", c.get(Calendar.MONTH)+1);
s[2]= String.format("%02d", c.get(Calendar.DATE));
return s;
}
public int getAvgCheckValue(Long proId,Date year){
String[] yearStr =formatDate(year);
Integer startYear = Integer.valueOf(yearStr[0])-3;
Integer endYear = Integer.valueOf(yearStr[0])+2;
ProjectOrg org = Org(proId);
if(org != null){
String sql ="SELECT ROUND(AVG(VALUE),0) AS AVGVALUE FROM HDS.T_CHECK_VALUE WHERE YEAR BETWEEN "+ startYear +" AND "+ endYear +" AND ORG_ID='"+ Org()+"'";
List<CheckValue> strList = vert2List(dao.queryForMapList(sql), CheckValue.class);
if(strList.size()>0){
java时间日期格式转换(0).getAvgValue();
}
}
return0;
}
以这种⽅式去取数组中的年⽉⽇数据
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论