English | 设为首页 | 加入收藏
  根据日期计算天数】 【极快分分彩正规吗:完成】 【曾壹鸣YY首秀开歌人气超佰】 【日博体系(PSCADA)
当前位置: 主页 > 当地租车 >

根据日期计算天数

时间:2018-11-06 12:27来源:未知 作者:admin 点击:
Calendar cal1= getCalendarFromDate(mStartDate); long startTime= cal1.getTimeInMillis(); Calendar cal2 = getCalendarFromDate(Untils.getdata(mEndDate); long endTime= cal2.getTimeInMillis(); int numberOfDays=(int) (endTime - startTime) / (24 *

  Calendar cal1= getCalendarFromDate(mStartDate);

  long startTime= cal1.getTimeInMillis();

  Calendar cal2 = getCalendarFromDate(Untils.getdata(mEndDate);

  long endTime= cal2.getTimeInMillis();

  int numberOfDays=(int) (endTime - startTime) / (24 * 60 * 60 * 1000);

  private Calendar getCalendarFromDate(final String date) {

  int year=0;

  int month=0;

  int day=0;

  try {

  String[] array =date.split("-");

  int[] arrayInt=new int[array.length];

  for (int i=0; i < array.length; i++) {

  arrayInt[i] = Integer.parseInt(array[i]);

  if (i==0) {

  year =arrayInt[0];

  } else if (i==1) {

  month =arrayInt[1];

  } else if (i==2) {

  day =arrayInt[2];

  }

  }

  } catch (Exception e) {

  e.printStackTrace();

  }

  Calendar cal = Calendar.getInstance();

  if (year > 0 && month >=0 && day >=0) {

  cal.set(year, month, day);

  }

  return cal;

  }

(责任编辑:admin)