Java Code Examples for java.util.Date#setMinutes()

The following examples show how to use java.util.Date#setMinutes() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = context.getLayoutInflater();
    View listViewItem = inflater.inflate(R.layout.layout_appointment_list, null, true);

    TextView textViewName = (TextView) listViewItem.findViewById(R.id.clinicName);
    TextView textViewDate = (TextView) listViewItem.findViewById(R.id.dateTime);
    TextView textViewService = (TextView) listViewItem.findViewById(R.id.clinicService);

    Booking booking = bookings.get(position);
    textViewName.setText(booking.getClinic().getName());
    String pattern = "yyyy-MM-dd HH:mm ";
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
    Date showDate = new Date();
    showDate.setHours(booking.getTime().getHours());
    showDate.setMinutes(booking.getTime().getMinutes());
    showDate.setDate(booking.getTime().getDate());
    showDate.setMonth(booking.getTime().getMonth());
    showDate.setYear(booking.getTime().getYear());

    String date = simpleDateFormat.format(showDate);
    textViewDate.setText(date);
    textViewService.setText(booking.getService().getName());
    return listViewItem;
}
 
Example 2
Source Project: JavaRush   File: Solution.java    License: MIT License 6 votes vote down vote up
@SuppressWarnings("deprecation")
private static boolean isDateOdd(String date) {
  boolean bool;
  Date date1 = new Date(date);
  Date ms = new Date(date);
  ms.setHours(0);
  ms.setMinutes(0);
  ms.setSeconds(0);
  ms.setMonth(0);
  ms.setDate(1);
  long num = date1.getTime() - ms.getTime();
  long dayMs = 24 * 60 * 60 * 1000;
  int day = (int) (num / dayMs);
  bool = day % 2 == 0;
  return bool;
}
 
Example 3
Source Project: TimeSelector   File: PowerDateUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 向前10分钟
 * 
 * @param date
 * @return
 */
public static String getNowGisDateForwardString(String date) {
	SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
	String str = null;
	try {
		Date curDate = new Date(
				formatter.parse(date).getTime() + 10 * 60 * 1000);
		curDate.setMinutes(curDate.getMinutes() / 10 * 10);
		str = formatter.format(curDate);
		Log.i("time", "getNowGisDateForwardString" + str);
	} catch (ParseException e) {
		e.printStackTrace();
	}
	return str;

}
 
Example 4
Source Project: TimeSelector   File: PowerDateUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 向后10分钟
 * 
 * @param date
 * @return
 */
public static String getNowGisDateBackwardsString(String date) {
	SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
	String str = null;
	try {
		Date curDate = new Date(
				formatter.parse(date).getTime() - 10 * 60 * 1000);
		curDate.setMinutes(curDate.getMinutes() / 10 * 10);
		str = formatter.format(curDate);
		Log.i("time", "getNowGisDateBackwardsString" + str);
	} catch (ParseException e) {
		e.printStackTrace();
	}
	return str;

}
 
Example 5
Source Project: Android-Allocine-Api   File: Horaires.java    License: Apache License 2.0 6 votes vote down vote up
public boolean isMoreThanToday() {
        try {
            String dateFormatted = getDate();

            Date now = new Date();
            now.setHours(0);
            now.setSeconds(0);
            now.setMinutes(0);

            SimpleDateFormat formater = new SimpleDateFormat("E dd MMMMM yyyy", Locale.FRANCE);
            Date date = formater.parse(dateFormatted);

            date.setHours(13);

            return date.equals(now) || date.after(now);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
}
 
Example 6
@Test
public void givenDate_whenHasOffset_thenConvertWithOffset() {
    TimeZone prevTimezone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

    Date date = new Date();
    date.setHours(6);
    date.setMinutes(30);

    OffsetDateTime odt = ConvertToOffsetDateTime.convert(date, 3, 30);
    assertEquals(10, odt.getHour());
    assertEquals(0, odt.getMinute());

    // Reset the timezone to its original value to prevent side effects
    TimeZone.setDefault(prevTimezone);
}
 
Example 7
Source Project: flink-learning   File: DateUtilTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testWithTimeAtEndOfNow() {
    Date date = new Date();
    date.setHours(23);
    date.setMinutes(59);
    date.setSeconds(59);
    String data = new SimpleDateFormat("yyyyMMddHHmmss").format(date);
    Assert.assertEquals(data, DateUtil.withTimeAtEndOfNow());
}
 
Example 8
Source Project: datacollector   File: TimeNowEL.java    License: Apache License 2.0 5 votes vote down vote up
@ElFunction(prefix = TIME_CONTEXT_VAR, name = "trimTime", description = "Set time portion of datetime expression to 00:00:00")
@SuppressWarnings("deprecation")
public static Date trimTime(@ElParam("datetime") Date in) {
  if(in == null) {
    return null;
  }

  Date ret = new Date(in.getTime());
  ret.setHours(0);
  ret.setMinutes(0);
  ret.setSeconds(0);
  return ret;
}
 
Example 9
Source Project: flink-learning   File: DateUtilTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testWithTimeAtStartOfNow() {
    Date date = new Date();
    date.setHours(0);
    date.setMinutes(0);
    date.setSeconds(0);
    String data = new SimpleDateFormat("yyyyMMddHHmmss").format(date);
    Assert.assertEquals(data, DateUtil.withTimeAtStartOfNow());
}
 
Example 10
Source Project: flink-learning   File: DateUtilTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testWithTimeAtEndOfNow() {
    Date date = new Date();
    date.setHours(23);
    date.setMinutes(59);
    date.setSeconds(59);
    String data = new SimpleDateFormat("yyyyMMddHHmmss").format(date);
    Assert.assertEquals(data, DateUtil.withTimeAtEndOfNow());
}
 
Example 11
Source Project: TimeSelector   File: PowerDateUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static String getNowGisDateString() {
	SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
	Date curDate = new Date(System.currentTimeMillis() - 20 * 60 * 1000);// 获取当前时间
	curDate.setMinutes(curDate.getMinutes() / 10 * 10);
	String str = formatter.format(curDate);
	Log.i("time", "getNowGisDateString" + str);
	return str;

}
 
Example 12
private Date createDate(Date date, String time) {
    if (time.length() == 5) {
        date.setHours(new Integer(time.substring(0, 2)));
        date.setMinutes(new Integer(time.substring(3, 5)));
    } else if (time.length() == 4) {
        date.setHours(new Integer(time.substring(0, 1)));
        date.setMinutes(new Integer(time.substring(2, 4)));
    }
    return date;
}
 
Example 13
@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;
}
 
Example 14
@Override
protected void putResults(Bundle results, String key) {
    Date res = new Date(day == null ? 0 : day);
    res.setHours(hour == null ? 0 : hour);
    res.setMinutes(minute == null ? 0 : minute);
    results.putLong(key, res.getTime());
}
 
Example 15
Source Project: j2objc   File: DateTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * java.util.Date#setMinutes(int)
 */
public void test_setMinutesI() {
    // Test for method void java.util.Date.setMinutes(int)
    Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9)
            .getTime();
    d.setMinutes(45);
    assertEquals("Set incorrect mins", 45, d.getMinutes());
}
 
Example 16
Source Project: unitime   File: ScriptPage.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public String getText() {
	Date date = iDate.getValue();
	if (date == null) return null;
	Integer slot = iTime.getValue();
	if (slot != null) {
		int h = (slot * 5) / 60;
		int m = (slot * 5) % 60;
		date.setHours(h); date.setMinutes(m);
	}
	return iFormat.format(date);
}
 
Example 17
@Override
public CreateOrderCondition getConditon() {
	CreateOrderCondition condition = new CreateOrderCondition();
		Date date = new Date();
		date = util.Tool.addDate(date, 1);
		Date date2 = util.Tool.addDate(date, 1);
		Date date3 = util.Tool.addDate(date, 0);
		date3.setHours(15);
		date3.setMinutes(0);
		date3.setSeconds(0);
		Date date4 = util.Tool.addDate(date, 0);
		date4.setHours(17);
		date4.setMinutes(0);
		date4.setSeconds(0);
		
		condition.setHotelId("10101129");
		condition.setRoomTypeId("0010");
		condition.setRatePlanId(145742);
		condition.setTotalPrice(new BigDecimal(600));
		condition.setAffiliateConfirmationId("my-order-id-2");
		
		condition.setArrivalDate(date);
		condition.setConfirmationType(elong.EnumConfirmationType.NotAllowedConfirm);
		condition.setContact(getContact());
		condition.setCreditCard(getCreditCard());
		condition.setCurrencyCode(elong.EnumCurrencyCode.HKD);
		condition.setCustomerIPAddress("211.151.230.21");
		condition.setCustomerType(elong.EnumGuestTypeCode.OtherForeign);
		condition.setDepartureDate(date2);
		condition.setEarliestArrivalTime(date3);
		condition.setExtendInfo(null);			
		condition.setInvoice(null);
		condition.setIsForceGuarantee(false);
		condition.setIsGuaranteeOrCharged(false);
		condition.setIsNeedInvoice(false);
		condition.setLatestArrivalTime(date4);
		condition.setNightlyRates(null);
		condition.setNoteToElong("");
		condition.setNoteToHotel(null);
		condition.setNumberOfCustomers(1);
		condition.setNumberOfRooms(1);
		condition.setOrderRooms( getRooms() );
		condition.setPaymentType(elong.EnumPaymentType.SelfPay);
		condition.setSupplierCardNo(null);
		
		
	
	return condition;
}
 
Example 18
protected Date nextIntervalDate(Date intervalMinDate, DateIntervalType intervalType, int intervals) {
    Date intervalMaxDate = new Date(intervalMinDate.getTime());

    if (MILLENIUM.equals(intervalType)) {
        intervalMaxDate.setYear(intervalMinDate.getYear() + 1000 * intervals);
    }
    else if (CENTURY.equals(intervalType)) {
        intervalMaxDate.setYear(intervalMinDate.getYear() + 100 * intervals);
    }
    else if (DECADE.equals(intervalType)) {
        intervalMaxDate.setYear(intervalMinDate.getYear() + 10 * intervals);
    }
    else if (YEAR.equals(intervalType)) {
        intervalMaxDate.setYear(intervalMinDate.getYear() +  intervals);
    }
    else if (QUARTER.equals(intervalType)) {
        intervalMaxDate.setMonth(intervalMinDate.getMonth() + 3 * intervals);
    }
    else if (MONTH.equals(intervalType)) {
        intervalMaxDate.setMonth(intervalMinDate.getMonth() + intervals);
    }
    else if (WEEK.equals(intervalType)) {
        intervalMaxDate.setDate(intervalMinDate.getDate() + 7 * intervals);
    }
    else if (DAY.equals(intervalType) || DAY_OF_WEEK.equals(intervalType)) {
        intervalMaxDate.setDate(intervalMinDate.getDate() + intervals);
    }
    else if (HOUR.equals(intervalType)) {
        intervalMaxDate.setHours(intervalMinDate.getHours() + intervals);
    }
    else if (MINUTE.equals(intervalType)) {
        intervalMaxDate.setMinutes(intervalMinDate.getMinutes() + intervals);
    }
    else if (SECOND.equals(intervalType)) {
        intervalMaxDate.setSeconds(intervalMinDate.getSeconds() + intervals);
    }
    else {
        // Default to year to avoid infinite loops
        intervalMaxDate.setYear(intervalMinDate.getYear() + intervals);
    }
    return intervalMaxDate;
}
 
Example 19
Source Project: MOOC   File: AdminController.java    License: MIT License 4 votes vote down vote up
@RequestMapping(value="banip")//封禁ip
public void banip(HttpServletResponse resp,HttpSession session,String ip,String mark,String time) throws IOException{
	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");
	if(time.equals("5m")) {
		if(date.getMinutes()>55) {
			date.setMinutes(date.getMinutes()-55);
			date.setHours(date.getHours()+1);
		}else {
		date.setMinutes(date.getMinutes()+5);
		}
		ip1.setBantime(date);
	}else if(time.equals("2h")) {
		date.setHours(date.getHours()+2);
		ip1.setBantime(date);
	}else if(time.equals("1d")) {
		date.setDate(date.getDate()+1);
		ip1.setBantime(date);
	}else if(time.equals("1m")) {
		date.setMonth(date.getMonth()+1);
		ip1.setBantime(date);
	}else if(time.equals("1y")) {
		date.setYear(date.getYear()+1);
		ip1.setBantime(date);
	}else if(time.equals("ever")) {
		date.setYear(date.getYear()+99);
		ip1.setBantime(date);
	}
	if(isnull) {
		ipsetBiz.insert(ip1);
	}else {
	ipsetBiz.updateByPrimaryKeySelective(ip1);
	}
	resp.setCharacterEncoding("utf-8");
	resp.getWriter().write("封禁成功!封禁至:"+date);
}
 
Example 20
@Override
public void handleMessage(byte[] data) {
    if (data.length < 15){
        failed = true;
        return;
    }
    DanaRPump pump = DanaRPump.getInstance();

    int dataIndex = DATA_START;
    int dataSize = 2;
    pump.iob = byteArrayToInt(getBytes(data, dataIndex, dataSize));

    dataIndex += dataSize;
    dataSize = 2;
    pump.dailyTotalUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;

    dataIndex += dataSize;
    dataSize = 1;
    pump.isExtendedInProgress = byteArrayToInt(getBytes(data, dataIndex, dataSize)) == 0x01;

    dataIndex += dataSize;
    dataSize = 2;
    pump.extendedBolusRemainingMinutes = byteArrayToInt(getBytes(data, dataIndex, dataSize));

    dataIndex += dataSize;
    dataSize = 2;
    double remainRate = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;

    Date lastBolusTime = new Date(); // it doesn't provide day only hour+min, workaround: expecting today
    dataIndex += dataSize;
    dataSize = 1;
    lastBolusTime.setHours(byteArrayToInt(getBytes(data, dataIndex, dataSize)));

    dataIndex += dataSize;
    dataSize = 1;
    lastBolusTime.setMinutes(byteArrayToInt(getBytes(data, dataIndex, dataSize)));

    dataIndex += dataSize;
    dataSize = 2;
    pump.lastBolusAmount = byteArrayToInt(getBytes(data, dataIndex, dataSize));
    // On DanaRS DailyUnits can't be more than 160
    if(pump.dailyTotalUnits > 160)
        failed = true;
    if (L.isEnabled(L.PUMPCOMM)) {
        log.debug("Daily total units: " + pump.dailyTotalUnits + " U");
        log.debug("Is extended in progress: " + pump.isExtendedInProgress);
        log.debug("Extended bolus remaining minutes: " + pump.extendedBolusRemainingMinutes);
        log.debug("Last bolus time: " + lastBolusTime.toLocaleString());
        log.debug("Last bolus amount: " + pump.lastBolusAmount);
    }
}