setDate ( )源码实例Demo

java.util.Date#setDate ( )源码实例Demo

下面列出了java.util.Date#setDate ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: doov   文件: DateTypeAdapter.java
@Override
@SuppressWarnings("deprecation")
public Object fromString(FieldInfo info, String value) {
    int year = Integer.parseInt(value.substring(0, 4));
    int month = Integer.parseInt(value.substring(4, 6));
    int day = Integer.parseInt(value.substring(6, 8));

    Date date = new Date();
    date.setDate(day);
    date.setMonth(month - 1);
    date.setYear(year - 1900);
    date.setHours(0);
    date.setMinutes(0);
    date.setSeconds(0);
    return date;
}
 
源代码2 项目: MiBandDecompiled   文件: cg.java
protected String a(SportDay sportday)
{
    Date date = new Date();
    SimpleDateFormat simpledateformat = new SimpleDateFormat();
    if (sportday.equals(StatisticFragment.C(q)))
    {
        return s;
    }
    if (sportday.offsetDay(StatisticFragment.C(q)) == -1 && !StatisticFragment.D(q))
    {
        return t;
    }
    if (1 + sportday.mon == 1 && sportday.day == 1)
    {
        date.setYear(sportday.year);
        date.setMonth(sportday.mon);
        date.setDate(sportday.day);
        simpledateformat.applyPattern(v);
    } else
    {
        date.setMonth(sportday.mon);
        date.setDate(sportday.day);
        simpledateformat.applyPattern(u);
    }
    return simpledateformat.format(date);
}
 
源代码3 项目: MuslimMateAndroid   文件: WeatherAdapter.java
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    Weather weather = weatherList.get(position);
    String[] time = weather.dayName.split(" ");
    String[] weatherTime = time[1].split(":");
    String[] date = time[0].split("-");
    SimpleDateFormat sdf = new SimpleDateFormat("EEEE");
    Date d = new Date();
    d.setYear(Integer.parseInt(date[0]));
    d.setMonth(Integer.parseInt(date[1]) - 1);
    d.setDate(Integer.parseInt(date[2]) - 1);
    String dayOfTheWeek = sdf.format(d);
    Log.d("DAY", weather.dayName + " : " + dayOfTheWeek);
    holder.dayName.setText(NumbersLocal.convertNumberType(context, weatherTime[0] + ":" + weatherTime[1] + ""));
    holder.weather.setText(NumbersLocal.convertNumberType(context, weather.tempMini + "°"));
    holder.image.setImageResource(WeatherIcon.get_icon_id_white(weather.image));
}
 
源代码4 项目: MiBandDecompiled   文件: StatisticDailyFragment.java
protected String formatDate(SportDay sportday)
{
    if (sportday.equals(mToday))
    {
        return getString(0x7f0d01b9);
    }
    if (sportday.addDay(1).equals(mToday) && !Locale.getDefault().toString().startsWith(Locale.ENGLISH.toString()))
    {
        return getString(0x7f0d005e);
    } else
    {
        SimpleDateFormat simpledateformat = new SimpleDateFormat(getString(0x7f0d0055));
        Date date = new Date();
        date.setMonth(sportday.mon);
        date.setDate(sportday.day);
        String s = simpledateformat.format(date);
        Object aobj[] = new Object[2];
        aobj[0] = s;
        aobj[1] = b[sportday.getWeek()];
        return getString(0x7f0d0057, aobj);
    }
}
 
源代码5 项目: MiBandDecompiled   文件: SportDay.java
public String formatStringDay()
{
    Date date = new Date();
    date.setYear(-1900 + year);
    date.setMonth(mon);
    date.setDate(day);
    return (new SimpleDateFormat(BraceletApp.getContext().getString(0x7f0d0055))).format(date);
}
 
源代码6 项目: j2objc   文件: DateTest.java
/**
 * java.util.Date#setDate(int)
 */
public void test_setDateI() {
    // Test for method void java.util.Date.setDate(int)
    Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9)
            .getTime();
    d.setDate(23);
    assertEquals("Set incorrect date", 23, d.getDate());
}
 
protected Date firstIntervalDate(DateIntervalType intervalType, Date minDate, ColumnGroup columnGroup) {
    Date intervalMinDate = new Date(minDate.getTime());
    if (YEAR.equals(intervalType)) {
        intervalMinDate.setMonth(0);
        intervalMinDate.setDate(1);
        intervalMinDate.setHours(0);
        intervalMinDate.setMinutes(0);
        intervalMinDate.setSeconds(0);
    }
    if (QUARTER.equals(intervalType)) {
        int currentMonth = intervalMinDate.getMonth();
        int firstMonthYear = columnGroup.getFirstMonthOfYear().getIndex();
        int rest = Quarter.getPositionInQuarter(firstMonthYear, currentMonth + 1);
        intervalMinDate.setMonth(currentMonth - rest);
        intervalMinDate.setDate(1);
        intervalMinDate.setHours(0);
        intervalMinDate.setMinutes(0);
        intervalMinDate.setSeconds(0);
    }
    if (MONTH.equals(intervalType)) {
        intervalMinDate.setDate(1);
        intervalMinDate.setHours(0);
        intervalMinDate.setMinutes(0);
        intervalMinDate.setSeconds(0);
    }
    if (DAY.equals(intervalType) || DAY_OF_WEEK.equals(intervalType) || WEEK.equals(intervalType)) {
        intervalMinDate.setHours(0);
        intervalMinDate.setMinutes(0);
        intervalMinDate.setSeconds(0);
    }
    if (HOUR.equals(intervalType)) {
        intervalMinDate.setMinutes(0);
        intervalMinDate.setSeconds(0);
    }
    if (MINUTE.equals(intervalType)) {
        intervalMinDate.setSeconds(0);
    }
    return intervalMinDate;
}
 
源代码8 项目: unitime   文件: SingleDateSelector.java
@SuppressWarnings("deprecation")
static int dayOfYear(int year, int month, int day) {
	Date d = new Date(year - 1900, month - 1, day);
	int doy = 0, y = d.getYear();
	while (d.getYear() == y) { d.setDate(d.getDate() - 1); doy ++; }
	return doy;
}
 
源代码9 项目: refactoring-kata   文件: ResidentialSite.java
public Dollars charge() {
    // find last reading
    int i = 0;
    while (readings[i] != null) i++;
    int usage = readings[i - 1].getAmount() - readings[i - 2].getAmount();
    Date end = readings[i - 1].getDate();
    Date start = readings[i - 2].getDate();
    start.setDate(start.getDate() + 1); //set to begining of period
    return charge(usage, start, end);
}
 
源代码10 项目: datacollector   文件: TimeNowEL.java
@ElFunction(prefix = TIME_CONTEXT_VAR, name = "trimDate", description = "Set date portion of datetime expression to January 1, 1970")
@SuppressWarnings("deprecation")
public static Date trimDate(@ElParam("datetime") Date in) {
  if(in == null) {
    return null;
  }

  Date ret = new Date(in.getTime());
  ret.setYear(70);
  ret.setMonth(0);
  ret.setDate(1);
  return ret;
}
 
@Test
public void shouldDisallowReportingDataSharingIfReportingIsInProgress() {
    Date lastReportedAt = new Date();
    lastReportedAt.setDate(lastReportedAt.getDate() - 1);
    UsageStatisticsReporting existingMetric = new UsageStatisticsReporting("server-id", lastReportedAt);
    when(usageStatisticsReportingSqlMapDao.load()).thenReturn(existingMetric);

    UsageStatisticsReporting statisticsReporting = service.get();
    assertTrue(statisticsReporting.canReport());
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    service.startReporting(result);
    assertTrue(result.isSuccessful());
    statisticsReporting = service.get();
    assertFalse(statisticsReporting.canReport());
}
 
源代码12 项目: mumu   文件: DateUtils.java
/**
 * 月的最后一天
 * 
 * @param date
 * @return
 */
@SuppressWarnings("deprecation")
public static Date getLastDayOfMonth(Date date) {
	Calendar cDay1 = Calendar.getInstance();
	cDay1.setTime(date);
	int lastDay = cDay1.getActualMaximum(Calendar.DAY_OF_MONTH);
	Date lastDate = cDay1.getTime();
	lastDate.setDate(lastDay);
	return lastDate;
}
 
源代码13 项目: Albianj2   文件: AlbianDateTime.java
@SuppressWarnings("deprecation")
public static Date dateAddSeconds(int year, int month, int day, long second) {
    Date dt = new Date();
    dt.setYear(year - 1900);
    dt.setMonth(month - 1);
    dt.setDate(day);
    dt.setHours(0);
    dt.setMinutes(0);
    dt.setSeconds(0);
    Calendar rightNow = Calendar.getInstance();
    rightNow.setTime(dt);
    rightNow.add(Calendar.SECOND, (int) second);
    Date dt1 = rightNow.getTime();
    return dt1;
}
 
源代码14 项目: roncoo-pay   文件: DateUtils.java
/**
 * 月的最后一天
 * 
 * @param date
 * @return
 */
@SuppressWarnings("deprecation")
public static Date getLastDayOfMonth(Date date) {
	Calendar cDay1 = Calendar.getInstance();
	cDay1.setTime(date);
	int lastDay = cDay1.getActualMaximum(Calendar.DAY_OF_MONTH);
	Date lastDate = cDay1.getTime();
	lastDate.setDate(lastDay);
	return lastDate;
}
 
源代码15 项目: KChartView   文件: KChartAdapter.java
@Override
public Date getDate(int position) {
    try {
        String s = datas.get(position).Date;
        String[] split = s.split("/");
        Date date = new Date();
        date.setYear(Integer.parseInt(split[0]) - 1900);
        date.setMonth(Integer.parseInt(split[1]) - 1);
        date.setDate(Integer.parseInt(split[2]));
        return date;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
源代码16 项目: unitime   文件: SingleDateSelector.java
@SuppressWarnings("deprecation")
public void addDays(int days) {
	Date d = getValue();
	if (d == null) {
		setDate(new Date());
	} else {
		d.setDate(d.getDate() + days);
		setDate(d);
	}
}
 
源代码17 项目: sms-ticket   文件: SmsParser.java
private Date parseDate(String text, String datePattern, SimpleDateFormat sdf, SimpleDateFormat sdfTime,
                       Ticket ticket) {
    Matcher m = Pattern.compile(datePattern).matcher(text);
    if (m.find()) {
        String d = m.group(1);
        if (!isEmpty(d)) {
            d = d.replaceAll(";", "");

            for (int i = 0; i < 2; i++) {
                final Date date;
                try {
                    if (i == 0) {
                        date = sdf.parse(d); // full date/time
                    } else if (i == 1 && sdfTime != null) {
                        date = sdfTime.parse(d); // only time
                    } else {
                        break;
                    }
                } catch (Exception e) {
                    continue;
                }

                if (i == 1 && ticket != null && ticket.validFrom != null) {
                    final Date prevDate = ticket.validFrom;
                    date.setYear(prevDate.getYear());
                    date.setMonth(prevDate.getMonth());
                    date.setDate(prevDate.getDate());
                }

                return date;
            }
        }
    }

    throw new RuntimeException("Cannot parse date from the message " + text);
}
 
源代码18 项目: freeacs   文件: ReportGeneratorTest.java
@Test
public void populateReportHWTable() throws SQLException {
  // Given:
  final Calendar calendar = Calendar.getInstance();
  calendar.set(Calendar.YEAR, 2018);
  calendar.set(Calendar.MONTH, 10);
  calendar.set(Calendar.DAY_OF_MONTH, 15);
  final ReportGenerator reportGenerator =
      new ReportGenerator("Test", ScheduleType.DAILY, null, null);
  final DataSource fakeDataSource = mock(DataSource.class);
  final Connection fakeConnection = mock(Connection.class);
  final PreparedStatement fakePreparedStatement = mock(PreparedStatement.class);
  when(fakeConnection.prepareStatement(anyString())).thenReturn(fakePreparedStatement);
  when(fakeDataSource.getConnection()).thenReturn(fakeConnection);
  final Report<RecordHardware> hardwareReport =
      new Report<>(RecordHardware.class, PeriodType.ETERNITY);
  final Date tms = new Date();
  tms.setYear(2018 - 1900);
  tms.setMonth(11 - 1);
  tms.setDate(1);
  final Key key =
      RecordHardware.keyFactory.makeKey(
          tms, PeriodType.DAY, "testunittype", "testprofile", "v1.0");
  final RecordHardware recordHardware =
      new RecordHardware(tms, PeriodType.DAY, "testunittype", "testprofile", "v1.0");
  hardwareReport.getMap().put(key, recordHardware);

  // When:
  reportGenerator.populateReportHWTable(fakeDataSource, hardwareReport, calendar);

  // Then:
  verify(fakeConnection)
      .prepareStatement(
          "insert into report_hw VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
  verify(fakePreparedStatement).executeUpdate();
  final long expectedTime = new TmsConverter(calendar).convert(tms, PeriodType.DAY).getTime();
  final Timestamp expectedTimestamp = new Timestamp(expectedTime);
  verify(fakePreparedStatement).setTimestamp(1, expectedTimestamp);
  verify(fakePreparedStatement).setInt(2, PeriodType.DAY.getTypeInt());
  verify(fakePreparedStatement).setString(3, "testunittype");
  verify(fakePreparedStatement).setString(4, "testprofile");
  verify(fakePreparedStatement).setString(5, "v1.0");
  verify(fakePreparedStatement).setInt(6, 0);
  verify(fakePreparedStatement).setInt(7, 0);
  verify(fakePreparedStatement).setInt(8, 0);
  verify(fakePreparedStatement).setInt(9, 0);
  verify(fakePreparedStatement).setInt(10, 0);
  verify(fakePreparedStatement).setInt(11, 0);
  verify(fakePreparedStatement).setInt(12, 0);
  verify(fakePreparedStatement).setInt(13, 0);
  verify(fakePreparedStatement).setInt(14, 0);
  verify(fakePreparedStatement).setInt(15, 0);
  verify(fakePreparedStatement).setString(16, null);
  verify(fakePreparedStatement).setString(17, null);
  verify(fakePreparedStatement).setString(18, null);
  verify(fakePreparedStatement).setString(19, null);
  verify(fakePreparedStatement).setString(20, null);
  verify(fakePreparedStatement).setString(21, null);
  verify(fakePreparedStatement).setString(22, null);
  verify(fakePreparedStatement).setString(23, null);
  verify(fakePreparedStatement).setString(24, null);
  verify(fakePreparedStatement).setString(25, null);
  verify(fakePreparedStatement).setString(26, null);
  verify(fakePreparedStatement).setString(27, null);
  verify(fakePreparedStatement).setString(28, null);
  verify(fakeConnection).close();
}
 
源代码19 项目: MOOC   文件: AdminController.java
@RequestMapping(value="banip")//封禁ip
public void banip(HttpServletResponse resp,HttpSession session,String ip,String mark,String time) throws IOException{
	User loginUser = (User) session.getAttribute("loginUser");
	if (loginUser == null) {
		return ;
	}else if(!"admin".equals(loginUser.getMission())){
		//添加管理员的再次验证
		return ;
	}
	Date date = new Date();
	Ipset ip1 = ipsetBiz.selectip(ip);
	boolean isnull = false;
	if(ip1==null) {
		ip1=new Ipset();
		ip1.setIp(ip);
		isnull =true;
	}
	ip1.setIp(ip);
	ip1.setMark(mark);
	ip1.setType("1");
	switch (time) {
		case "5m":
			if (date.getMinutes() > 55) {
				date.setMinutes(date.getMinutes() - 55);
				date.setHours(date.getHours() + 1);
			} else {
				date.setMinutes(date.getMinutes() + 5);
			}
			ip1.setBantime(date);
			break;
		case "2h":
			date.setHours(date.getHours() + 2);
			ip1.setBantime(date);
			break;
		case "1d":
			date.setDate(date.getDate() + 1);
			ip1.setBantime(date);
			break;
		case "1m":
			date.setMonth(date.getMonth() + 1);
			ip1.setBantime(date);
			break;
		case "1y":
			date.setYear(date.getYear() + 1);
			ip1.setBantime(date);
			break;
		case "ever":
			date.setYear(date.getYear() + 99);
			ip1.setBantime(date);
			break;
	}
	if(isnull) {
		ipsetBiz.insert(ip1);
	}else {
	ipsetBiz.updateByPrimaryKeySelective(ip1);
	}
	resp.setCharacterEncoding("utf-8");
	resp.getWriter().write("封禁成功!封禁至:"+date);
}
 
源代码20 项目: unitime   文件: ExportTimetablePDF.java
@SuppressWarnings("deprecation")
protected static Date getDate(Date firstDate, int date) {
   	Date ret = new Date(firstDate.getTime());
   	ret.setDate(ret.getDate() + date);
   	return ret;
   }