当前位置: 首页>>代码示例>>Java>>正文


Java Calendar.MINUTE属性代码示例

本文整理汇总了Java中java.util.Calendar.MINUTE属性的典型用法代码示例。如果您正苦于以下问题:Java Calendar.MINUTE属性的具体用法?Java Calendar.MINUTE怎么用?Java Calendar.MINUTE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.util.Calendar的用法示例。


在下文中一共展示了Calendar.MINUTE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: translate

private static int translate(final IntervalUnit unit) {
	switch (unit) {
	case DAY:
		return Calendar.DAY_OF_YEAR;
	case HOUR:
		return Calendar.HOUR_OF_DAY;
	case MINUTE:
		return Calendar.MINUTE;
	case MONTH:
		return Calendar.MONTH;
	case SECOND:
		return Calendar.SECOND;
	case MILLISECOND:
		return Calendar.MILLISECOND;
	case WEEK:
		return Calendar.WEEK_OF_YEAR;
	case YEAR:
		return Calendar.YEAR;
	default:
		throw new IllegalArgumentException("Unknown IntervalUnit");
	}
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:22,代码来源:DateUtil.java

示例2: getDateEnd

/**
 * @param dateAndResolution
 * @return String date
 */
public static String getDateEnd(Pair<Date, Integer> dateAndResolution)
{
    Calendar cal = Calendar.getInstance(I18NUtil.getLocale());
    cal.setTime(dateAndResolution.getFirst());
    switch (dateAndResolution.getSecond())
    {
        case Calendar.YEAR:
            cal.set(Calendar.MONTH, cal.getActualMaximum(Calendar.MONTH));
        case Calendar.MONTH:
            cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
        case Calendar.DAY_OF_MONTH:
            cal.set(Calendar.HOUR_OF_DAY, cal.getActualMaximum(Calendar.HOUR_OF_DAY));
        case Calendar.HOUR_OF_DAY:
            cal.set(Calendar.MINUTE, cal.getActualMaximum(Calendar.MINUTE));
        case Calendar.MINUTE:
            cal.set(Calendar.SECOND, cal.getActualMaximum(Calendar.SECOND));
        case Calendar.SECOND:
            cal.set(Calendar.MILLISECOND, cal.getActualMaximum(Calendar.MILLISECOND));
        case Calendar.MILLISECOND:
        default:
    }
    SimpleDateFormat formatter = CachingDateFormat.getSolrDatetimeFormat();
    formatter.setTimeZone(UTC_TIMEZONE);
    return formatter.format(cal.getTime());
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:29,代码来源:SearchDateConversion.java

示例3: parseTime

/**
 * Parse a raw phrase into a date {@link Date}
 *
 * @param str Raw phrase
 *
 * @return Date object
 */
public static Date parseTime(String str)
{
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());

    for (String t : str.split("\\+"))
    {
        String[] end = t.split(":");
        int type;

        if (end[1].equalsIgnoreCase("d"))
            type = Calendar.DAY_OF_YEAR;
        else if (end[1].equalsIgnoreCase("h"))
            type = Calendar.HOUR;
        else if (end[1].equalsIgnoreCase("m"))
            type = Calendar.MINUTE;
        else
            type = Calendar.SECOND;

        cal.add(type, Integer.parseInt(end[0]));
    }
    return cal.getTime();
}
 
开发者ID:SamaGames,项目名称:SamaGamesAPI,代码行数:30,代码来源:Misc.java

示例4: encode

public static String encode(String subject, ArrayList<String> roles) {
    // prepare expiration date according to application properties
    Date expDate = new Date();
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(expDate);

    int unit;
    switch (applicationProperties.getTokenExpiration().getUnit()) {
        case "SECOND":
            unit = Calendar.SECOND;
            break;
        case "MINUTE":
            unit = Calendar.MINUTE;
            break;
        default:
            unit = Calendar.HOUR;
    }

    calendar.add(unit, applicationProperties.getTokenExpiration().getValue());
    expDate = calendar.getTime();

    return Jwts.builder().setSubject(subject).claim("roles", roles).setIssuedAt(new Date()).setExpiration(expDate)
            .signWith(SignatureAlgorithm.HS256, key).compact();

}
 
开发者ID:jrtechnologies,项目名称:yum,代码行数:25,代码来源:JwtCodec.java

示例5: getMillisPerUnit

/**
 * Returns the number of millis of a datefield, if this is a constant value
 * 
 * @param unit A Calendar field which is a valid unit for a fragment
 * @return number of millis
 * @throws IllegalArgumentException if date can't be represented in millisenconds
 * @since 2.4 
 */
private static long getMillisPerUnit(int unit) {
    long result = Long.MAX_VALUE;
    switch (unit) {
        case Calendar.DAY_OF_YEAR:
        case Calendar.DATE:
            result = MILLIS_PER_DAY;
            break;
        case Calendar.HOUR_OF_DAY:
            result = MILLIS_PER_HOUR;
            break;
        case Calendar.MINUTE:
            result = MILLIS_PER_MINUTE;
            break;
        case Calendar.SECOND:
            result = MILLIS_PER_SECOND;
            break;
        case Calendar.MILLISECOND:
            result = 1;
            break;
        default: throw new IllegalArgumentException("The unit " + unit + " cannot be represented is milleseconds");
    }
    return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:DateUtils.java

示例6: getCalendarField

/**
 * Returns a field code (that can be used with the Calendar class) for a given 'unit' code.
 * The 'unit' is one of:  YEAR, MONTH, DAY, HOUR, MINUTE, SECOND and MILLISECOND.
 *
 * @param unit  the unit.
 *
 * @return the field code.
 */
private int getCalendarField(int unit) {

    switch (unit) {
        case (YEAR):
            return Calendar.YEAR;
        case (MONTH):
            return Calendar.MONTH;
        case (DAY):
            return Calendar.DATE;
        case (HOUR):
            return Calendar.HOUR_OF_DAY;
        case (MINUTE):
            return Calendar.MINUTE;
        case (SECOND):
            return Calendar.SECOND;
        case (MILLISECOND):
            return Calendar.MILLISECOND;
        default:
            return Calendar.MILLISECOND;
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:DateTickUnit.java

示例7: getInterval

/**
 * 获取时间间隔类型
 *
 * @param field
 *            时间间隔类型
 * @return 日历的时间间隔
 */
protected static int getInterval(String field) {
    String tmpField = field.toUpperCase();
    if (DEFAULT_YEAR.equals(tmpField)) {
        return Calendar.YEAR;
    } else if (DEFAULT_MONTH.equals(tmpField)) {
        return Calendar.MONTH;
    } else if (DEFAULT_DATE.equals(tmpField)) {
        return Calendar.DATE;
    } else if (DEFAULT_HOUR.equals(tmpField)) {
        return Calendar.HOUR;
    } else if (DEFAULT_MINUTE.equals(tmpField)) {
        return Calendar.MINUTE;
    } else {
        return Calendar.SECOND;
    }
}
 
开发者ID:PekingGo,项目名称:ipayquery,代码行数:23,代码来源:DateUtil.java

示例8: dateDiff

public static long dateDiff(Date startTime, Date endTime, int type) {
    long result = 0;
    long nd = 1000 * 24 * 60 * 60;// 一天的毫秒数
    long nh = 1000 * 60 * 60;// 一小时的毫秒数
    long nm = 1000 * 60;// 一分钟的毫秒数
    long ns = 1000;// 一秒钟的毫秒数
    long diff;
    try {
        // 获得两个时间的毫秒时间差异
        diff = endTime.getTime() - startTime.getTime();
        switch (type) {
            case Calendar.DATE:
                result = diff / nd;// 计算差多少天
                break;
            case Calendar.HOUR:
                result = diff % nd / nh;// 计算差多少小时
                break;
            case Calendar.MINUTE:
                result = diff % nd % nh / nm;// 计算差多少分钟
                break;
            case Calendar.SECOND:
                result = diff % nd % nh % nm / ns;// 计算差多少秒
                break;
            default:
                break;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}
 
开发者ID:Wangsu-Cloud-Storage,项目名称:wcs-android-sdk,代码行数:31,代码来源:DateUtil.java

示例9: compareDate

/**
 * 根据单位字段比较两个日期
 * 
 * @param date
 *            日期1
 * @param otherDate
 *            日期2
 * @param withUnit
 *            单位字段,从Calendar field取值
 * @return 等于返回0值, 大于返回大于0的值 小于返回小于0的值
 */
public static int compareDate(Date date, Date otherDate, int withUnit) {
	Calendar dateCal = Calendar.getInstance();
	dateCal.setTime(date);
	Calendar otherDateCal = Calendar.getInstance();
	otherDateCal.setTime(otherDate);

	switch (withUnit) {
	case Calendar.YEAR:
		dateCal.clear(Calendar.MONTH);
		otherDateCal.clear(Calendar.MONTH);
	case Calendar.MONTH:
		dateCal.set(Calendar.DATE, 1);
		otherDateCal.set(Calendar.DATE, 1);
	case Calendar.DATE:
		dateCal.set(Calendar.HOUR_OF_DAY, 0);
		otherDateCal.set(Calendar.HOUR_OF_DAY, 0);
	case Calendar.HOUR:
		dateCal.clear(Calendar.MINUTE);
		otherDateCal.clear(Calendar.MINUTE);
	case Calendar.MINUTE:
		dateCal.clear(Calendar.SECOND);
		otherDateCal.clear(Calendar.SECOND);
	case Calendar.SECOND:
		dateCal.clear(Calendar.MILLISECOND);
		otherDateCal.clear(Calendar.MILLISECOND);
	case Calendar.MILLISECOND:
		break;
	default:
		throw new IllegalArgumentException("withUnit 单位字段 " + withUnit + " 不合法!!");
	}
	return dateCal.compareTo(otherDateCal);
}
 
开发者ID:xubinux,项目名称:xbin-store,代码行数:43,代码来源:DateUtils.java

示例10: compareTime

/**
 * <p>Compares a calendar time value to another, indicating whether it is
 *    equal, less then or more than at a specified level.</p>
 *
 * @param value The Calendar value.
 * @param compare The <code>Calendar</code> to check the value against.
 * @param field The field <i>level</i> to compare to - e.g. specifying
 *        <code>Calendar.MINUTE</code> will compare the hours and minutes
 *        portions of the calendar.
 * @return Zero if the first value is equal to the second, -1
 *         if it is less than the second or +1 if it is greater than the second.
 */
protected int compareTime(Calendar value, Calendar compare, int field) {

    int result = 0;

    // Compare Hour
    result = calculateCompareResult(value, compare, Calendar.HOUR_OF_DAY);
    if (result != 0 || (field == Calendar.HOUR || field == Calendar.HOUR_OF_DAY)) {
        return result;
    }

    // Compare Minute
    result = calculateCompareResult(value, compare, Calendar.MINUTE);
    if (result != 0 || field == Calendar.MINUTE) {
        return result;
    }

    // Compare Second
    result = calculateCompareResult(value, compare, Calendar.SECOND);
    if (result != 0 || field == Calendar.SECOND) {
        return result;
    }

    // Compare Milliseconds
    if (field == Calendar.MILLISECOND) {
        return calculateCompareResult(value, compare, Calendar.MILLISECOND);
    }

    throw new IllegalArgumentException("Invalid field: " + field);

}
 
开发者ID:Ilhasoft,项目名称:data-binding-validator,代码行数:42,代码来源:AbstractCalendarValidator.java

示例11: Adjustment

public Adjustment(int field, int amount) {
	this.originalField = field;

	switch (field) {
		case CALENDAR_FIELD_YEAR:
			this.calendarField = Calendar.YEAR;
			break;
		case CALENDAR_FIELD_MONTH:
			this.calendarField = Calendar.MONTH;
			break;
		case CALENDAR_FIELD_DAY:
			this.calendarField = Calendar.DAY_OF_YEAR;
			break;
		case CALENDAR_FIELD_HOUR:
			this.calendarField = Calendar.HOUR_OF_DAY;
			break;
		case CALENDAR_FIELD_MINUTE:
			this.calendarField = Calendar.MINUTE;
			break;
		case CALENDAR_FIELD_SECOND:
			this.calendarField = Calendar.SECOND;
			break;
		case CALENDAR_FIELD_MILLISECOND:
			this.calendarField = Calendar.MILLISECOND;
			break;
	}

	this.amount = amount;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:29,代码来源:DateAdjust.java

示例12: getMethod

static ValueSource getMethod(IndexFieldData<?> fieldData, String fieldName, String method) {
    switch (method) {
        case GETVALUE_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
        case ISEMPTY_METHOD:
            return new EmptyMemberValueSource(fieldData);
        case SIZE_METHOD:
            return new CountMethodValueSource(fieldData);
        case MINIMUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MIN);
        case MAXIMUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MAX);
        case AVERAGE_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.AVG);
        case MEDIAN_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.MEDIAN);
        case SUM_METHOD:
            return new FieldDataValueSource(fieldData, MultiValueMode.SUM);
        case COUNT_METHOD:
            return new CountMethodValueSource(fieldData);
        case GET_YEAR_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.YEAR);
        case GET_MONTH_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.MONTH);
        case GET_DAY_OF_MONTH_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.DAY_OF_MONTH);
        case GET_HOUR_OF_DAY_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.HOUR_OF_DAY);
        case GET_MINUTES_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.MINUTE);
        case GET_SECONDS_METHOD:
            return new DateMethodValueSource(fieldData, MultiValueMode.MIN, method, Calendar.SECOND);
        default:
            throw new IllegalArgumentException("Member method [" + method + "] does not exist for date field [" + fieldName + "].");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:36,代码来源:DateField.java

示例13: compareTime

/**
 * 根据单位字段比较两个时间
 * 
 * @param date
 *            时间1
 * @param otherDate
 *            时间2
 * @param withUnit
 *            单位字段,从Calendar field取值
 * @return 等于返回0值, 大于返回大于0的值 小于返回小于0的值
 */
public static int compareTime(Date date, Date otherDate, int withUnit) {
	Calendar dateCal = Calendar.getInstance();
	dateCal.setTime(date);
	Calendar otherDateCal = Calendar.getInstance();
	otherDateCal.setTime(otherDate);

	dateCal.clear(Calendar.YEAR);
	dateCal.clear(Calendar.MONTH);
	dateCal.set(Calendar.DATE, 1);
	otherDateCal.clear(Calendar.YEAR);
	otherDateCal.clear(Calendar.MONTH);
	otherDateCal.set(Calendar.DATE, 1);
	switch (withUnit) {
	case Calendar.HOUR:
		dateCal.clear(Calendar.MINUTE);
		otherDateCal.clear(Calendar.MINUTE);
	case Calendar.MINUTE:
		dateCal.clear(Calendar.SECOND);
		otherDateCal.clear(Calendar.SECOND);
	case Calendar.SECOND:
		dateCal.clear(Calendar.MILLISECOND);
		otherDateCal.clear(Calendar.MILLISECOND);
	case Calendar.MILLISECOND:
		break;
	default:
		throw new IllegalArgumentException("withUnit 单位字段 " + withUnit + " 不合法!!");
	}
	return dateCal.compareTo(otherDateCal);
}
 
开发者ID:babymm,项目名称:mumu,代码行数:40,代码来源:DateUtils.java

示例14: translate

private static int translate(IntervalUnit unit) {
    switch(unit) {
        case DAY : return Calendar.DAY_OF_YEAR;
        case HOUR : return Calendar.HOUR_OF_DAY;
        case MINUTE : return Calendar.MINUTE;
        case MONTH : return Calendar.MONTH;
        case SECOND : return Calendar.SECOND;
        case MILLISECOND : return Calendar.MILLISECOND;
        case WEEK : return Calendar.WEEK_OF_YEAR;
        case YEAR : return Calendar.YEAR;
        default : throw new IllegalArgumentException("Unknown IntervalUnit");
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:DateBuilder.java

示例15: getFutureTimeRelativeTo

public long getFutureTimeRelativeTo(long time)
{
	int valueToUse = (int) value;
	int field = 0;
	if (getUnit() == TimeUnit.MILLISECONDS)
	{
		field = Calendar.MILLISECOND;
		//we do our own adjustment as calendar cannot handle a long.
		time += value;
		valueToUse = 0;
	}
	else if (getUnit() == TimeUnit.SECONDS)
		field = Calendar.SECOND;
	else if (getUnit() == TimeUnit.MINUTES)
		field = Calendar.MINUTE;
	else if (getUnit() == TimeUnit.HOURS)
		field = Calendar.HOUR;
	else if (getUnit() == TimeUnit.DAYS)
		field = Calendar.DATE;
	else if (getUnit() == TimeUnit.WEEKS)
		field = Calendar.WEEK_OF_MONTH;
	else if (getUnit() == TimeUnit.MONTHS)
		field = Calendar.MONTH;
	else if (getUnit() == TimeUnit.YEARS)
		field = Calendar.YEAR;

	calendar.setTimeInMillis(time);
	calendar.add(field, valueToUse);

	return calendar.getTime().getTime();
}
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:31,代码来源:RelativeTime.java


注:本文中的java.util.Calendar.MINUTE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。