Calendar getActualMaximum - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Calendar getActualMaximum method.

This code example shows how to use the following methods:getActualMaximum, set
     * @param calendar The {@link java.util.Calendar} whose {@link java.util.Calendar#MONTH} field will be used 
     *                 as the current month 
     * @return 
     */ 
    public static int getLastDateOfMonth(Calendar calendar) {
        Calendar tmpCal = new GregorianCalendar(calendar.getTimeZone());
        tmpCal.set(Calendar.YEAR, calendar.get(Calendar.YEAR));
        tmpCal.set(Calendar.MONTH, calendar.get(Calendar.MONTH));
        tmpCal.set(Calendar.DAY_OF_MONTH, 1);
        return tmpCal.getActualMaximum(Calendar.DAY_OF_MONTH);
    } 
 
    public static Integer getNthDayOfMonth(Calendar cal, int n, int dayOfWeek) {
        int dateOfFirstXXXDay = getFirstDateInMonthForDayOfWeek(cal, dayOfWeek);
 
        final int FIRST_WEEK = 1;
        final int NUM_DAYS_IN_WEEK = 7;
 
        int weekDiff = n - FIRST_WEEK;
 
8
CodeRank
This code example shows how to use the following methods:equals, get, getActualMaximum, getActualMinimum
7
CodeRank
This code example shows how to use the following methods:getActualMaximum, set
 
        return copy;
    } 
 
    private boolean monthHasDate(Calendar cal, int date) {
        Calendar tmpCal = new GregorianCalendar(cal.getTimeZone());
        tmpCal.set(Calendar.YEAR, cal.get(Calendar.YEAR));
        tmpCal.set(Calendar.MONTH, cal.get(Calendar.MONTH));
        tmpCal.set(Calendar.DAY_OF_MONTH, 1);
        int maximumPossibleDateForTheMonth = tmpCal.getActualMaximum(Calendar.DAY_OF_MONTH);
 
        if (date > maximumPossibleDateForTheMonth) {
            return false; 
        } 
        return true; 
 
    } 
 
    private boolean isAfterEnd(Calendar cal) {
        Date end = this.scheduleExpression.getEnd();
7
CodeRank
This code example shows how to use the following methods:get, getActualMaximum, getTimeInMillis, set
        long endTime = c.getTimeInMillis();
        return new TimeObject(String.format(formatString, c,c), startTime, endTime);
    } 
 
    public static TimeObject getMonth(Calendar c, String formatString) {
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        // set calendar to first millisecond of the month 
        c.set(year, month, 1, 0, 0, 0);
        c.set(Calendar.MILLISECOND, 0);
        long startTime = c.getTimeInMillis();
        // set calendar to last millisecond of the month 
        c.set(year, month, c.getActualMaximum(Calendar.DAY_OF_MONTH), 23, 59, 59);
        c.set(Calendar.MILLISECOND, 999);
        long endTime = c.getTimeInMillis();
        return new TimeObject(String.format(formatString,c,c), startTime, endTime);
    } 
 
    public static TimeObject getDay(Calendar c, String formatString) {
        int year = c.get(Calendar.YEAR);
7
CodeRank
This code example shows how to use the following methods:get, getActualMaximum, set
 
    	mView = view;
 
    	// Highlight today. 
    	final Calendar now = Calendar.getInstance();
		if (month.get(Calendar.YEAR) == now.get(Calendar.YEAR)
				&& month.get(Calendar.MONTH) == now.get(Calendar.MONTH)) {
			mCurrentDay = now.get(Calendar.DAY_OF_MONTH);
		} else { 
			mCurrentDay = null;
		} 
    	 
		final Calendar calendar = (Calendar) month;
		calendar.set(Calendar.DAY_OF_MONTH, 1);		
        mYear = calendar.get(Calendar.YEAR);
        mMonth = calendar.get(Calendar.MONTH);        
    	lastDayOfMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    	dayOfWeekOfFirstDay = calendar.get(Calendar.DAY_OF_WEEK);
		calendar.set(Calendar.DAY_OF_MONTH, lastDayOfMonth);		
		dayOfWeekOfLasttDay = calendar.get(Calendar.DAY_OF_WEEK);    	

6
CodeRank
This code example shows how to use the following methods:getActualMaximum, getTime, set, setTime
		if (dateText == null) {
			return null; 
		} 
		 
		try { 
			calendar.setTime(standardFormatter.parse(dateText.toString()));
			int lastDate = calendar.getActualMaximum(calendar.DATE);
			calendar.set(Calendar.DATE,lastDate);
			calendar.set(Calendar.HOUR_OF_DAY, 0);  
			calendar.set(Calendar.MINUTE, 0);  
			calendar.set(Calendar.SECOND, 0);  
			calendar.set(Calendar.MILLISECOND, 0); 
			Date newDate = calendar.getTime();
			result.set(standardFormatter.format(newDate));
			return result;
		} catch (ParseException e) {
			e.printStackTrace();
			return null; 
		} 
	} 
6
CodeRank
This code example shows how to use the following methods:add, getActualMaximum, getTime, set, setTime
        Date retValue = null;
        List<Integer> results = new OrderProcessDAS().findActiveInvoicesForOrder(order.getId());
        if ( !results.isEmpty() && order.getNextBillableDay() != null) {
            retValue = order.getNextBillableDay();
        } else if (order.getUser().getCustomer().getMainSubscription() != null) {
        	Calendar cal = new GregorianCalendar();
        	MainSubscriptionDTO mainSubscription = order.getUser().getCustomer().getMainSubscription();
            Integer nextInvoiceDaysOfPeriod = mainSubscription.getNextInvoiceDayOfPeriod();
            Integer mainSubscriptionPeriodUnit = mainSubscription.getSubscriptionPeriod().getPeriodUnit().getId();
            Integer mainSubscriptionPeriodValue = mainSubscription.getSubscriptionPeriod().getValue();
 
            cal.setTime(order.getActiveSince() != null ? order.getActiveSince() : order.getCreateDate());
             
    		cal.set(Calendar.DAY_OF_MONTH, 1);
 
            // consider end of month case 
            if (cal.getActualMaximum(Calendar.DAY_OF_MONTH) <= nextInvoiceDaysOfPeriod &&
                    Constants.PERIOD_UNIT_MONTH.equals(mainSubscriptionPeriodUnit)) {
                cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
            } else { 

6
CodeRank
This code example shows how to use the following methods:add, getActualMaximum, set
		return _periodLength;
	} 
 
	public static int getPeriodLength(int offset) {
		if (_isMonthlyPeriod()) { 
			Calendar calendar = new GregorianCalendar();
 
			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, 0);
 
			calendar.add(Calendar.MONTH, offset);
 
			return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
		} 
 
		return getPeriodLength(); 
	} 
 
7
CodeRank
This code example shows how to use the following methods:getActualMaximum, getTime
    public MediaItem getItem(Long id) {
        return em.find(MediaItem.class, id);
    } 
 
    public MediaItem getItem(int year, int month, String name) throws NoResultException {
        Calendar startDate = new GregorianCalendar(year, month-1, 1);
        Calendar endDate = new GregorianCalendar(year, month-1, startDate.getActualMaximum(Calendar.DAY_OF_MONTH));
        TypedQuery<MediaItem> query = em.createQuery(
                "SELECT mi from MediaItem mi WHERE mi.uploadedDate >= :START AND mi.uploadedDate <= :END AND mi.name = :NAME", 
                MediaItem.class); 
        query.setParameter("START", startDate.getTime());
        query.setParameter("END", endDate.getTime());
        query.setParameter("NAME", name);
        return query.getSingleResult();
    } 
 
    public List<MediaItem> getItems() {
        return em.createQuery("SELECT mi from MediaItem mi", MediaItem.class)
                .getResultList(); 
    } 
6
CodeRank
This code example shows how to use the following methods:get, getActualMaximum, getTimeInMillis, set
        long endTime = c.getTimeInMillis();
        return new TimeObject(String.format(formatString, c,c), startTime, endTime);
    } 
 
    public static TimeObject getMonth(Calendar c, String formatString) {
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        // set calendar to first millisecond of the month 
        c.set(year, month, 1, 0, 0, 0);
        c.set(Calendar.MILLISECOND, 0);
        long startTime = c.getTimeInMillis();
        // set calendar to last millisecond of the month 
        c.set(year, month, c.getActualMaximum(Calendar.DAY_OF_MONTH), 23, 59, 59);
        c.set(Calendar.MILLISECOND, 999);
        long endTime = c.getTimeInMillis();
        return new TimeObject(String.format(formatString,c,c), startTime, endTime);
    } 
 
    public static TimeObject getDay(Calendar c, String formatString) {
        int year = c.get(Calendar.YEAR);
6
CodeRank

Related Calendar getActualMaximum Questions & Answers:

getActualMaximum Method Overview
Returns the maximum value that the specified calendar field could have, given the time value of this Calendar.
See Code Examples for other Java 8 Calendar Methods: