當前位置: 首頁>>代碼示例>>Java>>正文


Java Calendar.WEEK_OF_YEAR屬性代碼示例

本文整理匯總了Java中java.util.Calendar.WEEK_OF_YEAR屬性的典型用法代碼示例。如果您正苦於以下問題:Java Calendar.WEEK_OF_YEAR屬性的具體用法?Java Calendar.WEEK_OF_YEAR怎麽用?Java Calendar.WEEK_OF_YEAR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.util.Calendar的用法示例。


在下文中一共展示了Calendar.WEEK_OF_YEAR屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: previous

/**
 * Operation is based on java util calendar in order to support daylight
 * saving times.
 */
public TimeSlice previous() {
    long newStart = start;
    long newEnd = end;
    Calendar temp = Calendar.getInstance();
    temp.setTimeInMillis(start);
    int field = 0;
    switch (period) {
    case HOUR:
        field = Calendar.HOUR_OF_DAY;
        break;
    case DAY:
        field = Calendar.DAY_OF_MONTH;
        break;
    case WEEK:
        field = Calendar.WEEK_OF_YEAR;
        break;
    case MONTH:
        field = Calendar.MONTH;
        break;
    default:
        break;
    }
    temp.add(field, -1);
    newStart = temp.getTimeInMillis();
    temp.setTimeInMillis(end);
    temp.add(field, -1);
    newEnd = temp.getTimeInMillis();
    return new TimeSlice(newStart, newEnd, period);
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:33,代碼來源:TimeSlice.java

示例3: 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

示例4: getDateFieldFromRepeatType

private static int getDateFieldFromRepeatType(ReminderRepeatType repeatType) {

        switch (repeatType) {
            case DAILY: return Calendar.DAY_OF_MONTH;
            case WEEKLY: return Calendar.WEEK_OF_YEAR;
            case MONTHLY: return Calendar.MONTH;
            case YEARLY: return Calendar.YEAR;
            default: throw new InvalidParameterException("Invalid RepeatType parameter in TaskUtil.getRepeatingReminderEndCalendar()");
        }
    }
 
開發者ID:abicelis,項目名稱:Remindy,代碼行數:10,代碼來源:TaskUtil.java

示例5: checkTime

private boolean checkTime(Date date, int kind) {
    Calendar currentCalendar = Calendar.getInstance();
    currentCalendar.setTime(Utils.getAnalyticsDate());

    Calendar orderCalendar = Calendar.getInstance();
    orderCalendar.setTime(date);
    switch (kind) {
        case Calendar.DATE:
            if (orderCalendar.get(Calendar.YEAR) == currentCalendar.get(Calendar.YEAR) &&
                    orderCalendar.get(Calendar.MONTH) == currentCalendar.get(Calendar.MONTH) &&
                    orderCalendar.get(Calendar.DATE) == currentCalendar.get(Calendar.DAY_OF_MONTH)) {
                return true;
            }
            break;
        case Calendar.WEEK_OF_YEAR:
            if (orderCalendar.get(Calendar.YEAR) == currentCalendar.get(Calendar.YEAR) &&
                    orderCalendar.get(Calendar.WEEK_OF_YEAR) == currentCalendar.get(Calendar.WEEK_OF_YEAR)) {
                return true;
            }
            break;
        case Calendar.MONTH:
            if (orderCalendar.get(Calendar.YEAR) == currentCalendar.get(Calendar.YEAR) &&
                    orderCalendar.get(Calendar.MONTH) == currentCalendar.get(Calendar.MONTH)) {
                return true;
            }
            break;
        default:
            return false;
    }
    return false;
}
 
開發者ID:Wisebite,項目名稱:wisebite_android,代碼行數:31,代碼來源:RestaurantService.java

示例6: makeDatesEven

/**
 * Makes dates even, in the sense of that years always begin in January,
 * months always begin on the 1st and days always at midnight.
 *
 * @param dates The list of dates.
 * @return The new list of dates.
 */
private List<Date> makeDatesEven(List<Date> dates, Calendar calendar) {
    // If the dates contain more dates than just the lower and upper bounds, make the dates in between even.
    if (dates.size() > 2) {
        List<Date> evenDates = new ArrayList<>();

        // For each interval, modify the date slightly by a few millis, to make sure they are different days.
        // This is because Axis stores each value and won't update the tick labels, if the value is already known.
        // This happens if you display days and then add a date many years in the future the tick label will still be displayed as day.
        for (int i = 0; i < dates.size(); i++) {
            calendar.setTime(dates.get(i));
            switch (actualInterval.interval) {
                case Calendar.YEAR:
                    // If its not the first or last date (lower and upper bound), make the year begin with first month and let the months begin with first day.
                    if (i != 0 && i != dates.size() - 1) {
                        calendar.set(Calendar.MONTH, 0);
                        calendar.set(Calendar.DATE, 1);
                    }
                    calendar.set(Calendar.HOUR_OF_DAY, 0);
                    calendar.set(Calendar.MINUTE, 0);
                    calendar.set(Calendar.SECOND, 0);
                    calendar.set(Calendar.MILLISECOND, 6);
                    break;
                case Calendar.MONTH:
                    // If its not the first or last date (lower and upper bound), make the months begin with first day.
                    if (i != 0 && i != dates.size() - 1) {
                        calendar.set(Calendar.DATE, 1);
                    }
                    calendar.set(Calendar.HOUR_OF_DAY, 0);
                    calendar.set(Calendar.MINUTE, 0);
                    calendar.set(Calendar.SECOND, 0);
                    calendar.set(Calendar.MILLISECOND, 5);
                    break;
                case Calendar.WEEK_OF_YEAR:
                    // Make weeks begin with first day of week?
                    calendar.set(Calendar.HOUR_OF_DAY, 0);
                    calendar.set(Calendar.MINUTE, 0);
                    calendar.set(Calendar.SECOND, 0);
                    calendar.set(Calendar.MILLISECOND, 4);
                    break;
                case Calendar.DATE:
                    calendar.set(Calendar.HOUR_OF_DAY, 0);
                    calendar.set(Calendar.MINUTE, 0);
                    calendar.set(Calendar.SECOND, 0);
                    calendar.set(Calendar.MILLISECOND, 3);
                    break;
                case Calendar.HOUR:
                    if (i != 0 && i != dates.size() - 1) {
                        calendar.set(Calendar.MINUTE, 0);
                        calendar.set(Calendar.SECOND, 0);
                    }
                    calendar.set(Calendar.MILLISECOND, 2);
                    break;
                case Calendar.MINUTE:
                    if (i != 0 && i != dates.size() - 1) {
                        calendar.set(Calendar.SECOND, 0);
                    }
                    calendar.set(Calendar.MILLISECOND, 1);
                    break;
                case Calendar.SECOND:
                    calendar.set(Calendar.MILLISECOND, 0);
                    break;

            }
            evenDates.add(calendar.getTime());
        }

        return evenDates;
    } else {
        return dates;
    }
}
 
開發者ID:dainesch,項目名稱:HueSense,代碼行數:78,代碼來源:DateAxis.java

示例7: getAllOrdersCount

public PieChartData getAllOrdersCount(String restaurantId, int kind) {
    float[] time;
    if (kind == Calendar.DATE) time = new float[24];
    else if (kind == Calendar.WEEK_OF_YEAR) time = new float[7];
    else time = new float[31];
    for (int i = 0; i < time.length; i++) time[i] = 0;

    List<String> ordersList = getOrders(restaurantId);

    Calendar calendar = Calendar.getInstance();
    Order order;
    for (String orderKey : ordersList) {
        order = orderRepository.get(orderKey);
        if (checkTime(order.getDate(), kind)) {
            calendar.setTime(order.getDate());
            if (kind == Calendar.DATE)
                time[calendar.get(Calendar.HOUR_OF_DAY)] += 1.0f;
            else if (kind == Calendar.WEEK_OF_YEAR)
                time[calendar.get(Calendar.DAY_OF_WEEK)-1] += 1.0f;
            else
                time[calendar.get(Calendar.DAY_OF_MONTH)] += 1.0f;
        }
    }

    Integer count = 0;
    for (float t : time) if (t != 0) ++count;

    PieChartData data = new PieChartData(count);
    String[] xData = data.getXData();
    float[] yData = data.getYData();

    Integer j = 0;
    for (int i = 0; i < time.length; i++) {
        if (time[i] != 0) {
            yData[j] = time[i];


            String label = "";
            if (kind == Calendar.DATE) {
                if (i < 10) label += '0';
                label += String.valueOf(i) + "h - ";
                if (i + 1 < 10) label += '0';
                label += String.valueOf(i + 1) + 'h';
            } else if (kind == Calendar.WEEK_OF_YEAR) {
                if (i == 0) label = "Sunday";
                else if (i == 1) label = "Monday";
                else if (i == 2) label = "Tuesday";
                else if (i == 3) label = "Wednesday";
                else if (i == 4) label = "Thursday";
                else if (i == 5) label = "Friday";
                else if (i == 6) label = "Saturday";
            } else {
                label = "Day number " + String.valueOf(i) + " of the month.";
            }
            xData[j] = label;

            ++j;
        }
    }

    data.setXData(xData);
    data.setYData(yData);
    return data;
}
 
開發者ID:Wisebite,項目名稱:wisebite_android,代碼行數:64,代碼來源:RestaurantService.java


注:本文中的java.util.Calendar.WEEK_OF_YEAR屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。