//年的判断***********************
public static String changeLoginYear(String y)
{
if(y == null || y.equals(""))return "";
int year =Integer.parseInt(y);
if(year>=1925 && year<=1988)
return "S"+ (year-1925);
else if(year>1988)
return "H"+ (year-1988);
else
return "";
}
//
/*****************************************判断剩余的时间
*
* @param date1
* 被减数时间
*
* @param date2
* 减数时间
* @param datteStyle
* 如:yyyy-MM-dd HH:mm:ss
* @return
*/
public static String dateSubtract(String date1, String date2,
String dateStyle) {
SimpleDateFormat sdf = new SimpleDateFormat(dateStyle);
if (date1 == null || "".equals(date1))
return "";
if (date2 == null || "".equals(date2))
return "";
try {
Date d1 = sdf.parse(date1);
Date d2 = sdf.parse(date2);
return dateSubtract(d1, d2);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public static String dateSubtract(Date date1, Date date2) {
if (date1 == null)
return "";
if (date2 == null)
return "";
long t11 = date1.getTime();
long t22 = date2.getTime();
long dist = t11 - t22;
long ms = dist % 1000;
dist = dist / 1000;
long sc = dist % 60;
dist = dist / 60;
long mn = dist % 60;
dist = dist / 60;
long hr = dist % 24;
dist = dist / 24;
if (dist < 0 || hr < 0 || mn < 0)
return "0日";
if (dist <= 0)
return hr + ":" + mn;
if (hr <= 0 && mn <= 0)
return dist + "日";
return dist + "日" + hr + ":" + mn;
}