Java Code Examples for com.ibm.icu.util.Calendar#get()

The following examples show how to use com.ibm.icu.util.Calendar#get() . 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 check out the related API usage on the sidebar.
Example 1
Source File: TrailingFunction.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Check if date1 is in the same time period ( month/ year ) with date2.
 * If not, return date1, else return null.
 * @param date1
 * @param date2
 * @param extraWeekLevel
 * @return
 */
private Calendar getExtraWeek(Calendar date1, Calendar date2,
		String extraWeekLevel) {
	
	if ( extraWeekLevel.equals( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH ) )
	{
		if ( date1.get( Calendar.MONTH ) != date2.get( Calendar.MONTH ) )
			return date1;
	}
	if ( extraWeekLevel.equals( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_YEAR ) )
	{
		if ( date1.get( Calendar.YEAR ) != date2.get( Calendar.YEAR ) )
			return date1;
	}
	
	return null;
}
 
Example 2
Source File: TemporalExpressions.java    From scipio-erp with Apache License 2.0 6 votes vote down vote up
@Override
public boolean includesDate(Calendar cal) {
    int dow = cal.get(Calendar.DAY_OF_WEEK);
    if (dow == this.start || dow == this.end) {
        return true;
    }
    Calendar compareCal = (Calendar) cal.clone();
    while (compareCal.get(Calendar.DAY_OF_WEEK) != this.start) {
        compareCal.add(Calendar.DAY_OF_MONTH, 1);
    }
    while (compareCal.get(Calendar.DAY_OF_WEEK) != this.end) {
        if (compareCal.get(Calendar.DAY_OF_WEEK) == dow) {
            return true;
        }
        compareCal.add(Calendar.DAY_OF_MONTH, 1);
    }
    return false;
}
 
Example 3
Source File: TemporalExpressions.java    From scipio-erp with Apache License 2.0 6 votes vote down vote up
@Override
public boolean includesDate(Calendar cal) {
    int hour = cal.get(Calendar.HOUR_OF_DAY);
    if (hour == this.start || hour == this.end) {
        return true;
    }
    Calendar compareCal = (Calendar) cal.clone();
    compareCal.set(Calendar.HOUR_OF_DAY, this.start);
    while (compareCal.get(Calendar.HOUR_OF_DAY) != this.end) {
        if (compareCal.get(Calendar.HOUR_OF_DAY) == hour) {
            return true;
        }
        compareCal.add(Calendar.HOUR_OF_DAY, 1);
    }
    return false;
}
 
Example 4
Source File: BirtDateTime.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected Object getValue( Object[] args, IScriptFunctionContext context ) throws BirtException
{
	if ( existNullValue( args ) )
	{
		return null;
	}
	Calendar current = getCalendar( DataTypeUtil.toDate( args[0] ) );
	Calendar start = getFiscalYearStateDate( context, args );
	if ( start.get( Calendar.DAY_OF_YEAR ) > 1 )
	{
		adjustFiscalYear( current, start );
		// Fiscal year should return next year of first day, except
		// Jan. 1
		return current.get( Calendar.YEAR ) + 1;
	}
	return current.get( Calendar.YEAR );
}
 
Example 5
Source File: TemporalExpressions.java    From scipio-erp with Apache License 2.0 6 votes vote down vote up
protected Calendar alignDayOfWeek(Calendar cal) {
    cal.set(Calendar.DAY_OF_MONTH, 1);
    if (this.occurrence > 0) {
        while (cal.get(Calendar.DAY_OF_WEEK) != this.dayOfWeek) {
            cal.add(Calendar.DAY_OF_MONTH, 1);
        }
        cal.add(Calendar.DAY_OF_MONTH, (this.occurrence - 1) * 7);
    } else {
        cal.add(Calendar.MONTH, 1);
        cal.add(Calendar.DAY_OF_MONTH, -1);
        while (cal.get(Calendar.DAY_OF_WEEK) != this.dayOfWeek) {
            cal.add(Calendar.DAY_OF_MONTH, -1);
        }
        cal.add(Calendar.DAY_OF_MONTH, (this.occurrence + 1) * 7);
    }
    return cal;
}
 
Example 6
Source File: SpinnerTable.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void setOriValue( )
{
	Calendar tempcalendar = getOriCalendar( cale );
	//		int dayCount = tempcalendar.getActualMaximum( Calendar.DAY_OF_MONTH
	// );
	int moreDayCount = tempcalendar.get( Calendar.DAY_OF_WEEK ) - 1;

	int selectDay = cale.get( Calendar.DAY_OF_MONTH )
			+ moreDayCount
			+ DAY_WEEK_COUNT;

	int week = selectDay
			- ( ( selectDay / DAY_WEEK_COUNT ) * DAY_WEEK_COUNT )
			- 1;
	int row = selectDay / DAY_WEEK_COUNT;
	if ( week == -1 )
	{
		week = 6;
		row = row - 1;
	}

	cursor.setSelection( row, week );
}
 
Example 7
Source File: TemporalExpressions.java    From scipio-erp with Apache License 2.0 6 votes vote down vote up
@Override
public boolean includesDate(Calendar cal) {
    int month = cal.get(Calendar.MONTH);
    if (month == this.start || month == this.end) {
        return true;
    }
    Calendar compareCal = (Calendar) cal.clone();
    while (compareCal.get(Calendar.MONTH) != this.start) {
        compareCal.add(Calendar.MONTH, 1);
    }
    while (compareCal.get(Calendar.MONTH) != this.end) {
        if (compareCal.get(Calendar.MONTH) == month) {
            return true;
        }
        compareCal.add(Calendar.MONTH, 1);
    }
    return false;
}
 
Example 8
Source File: AbstractMDX.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void setAcrossMonthWeekDay(Calendar cal, int monthBase)
{
	int month = cal.get( Calendar.MONTH );
	if ( month == monthBase )
	{
		return;
	}

	cal.set( Calendar.DAY_OF_WEEK, 1 );
	int monthStart = cal.get( Calendar.MONTH );

	if ( monthStart == monthBase )
	{
		return;
	}

	cal.set( Calendar.DAY_OF_WEEK, 7 );

}
 
Example 9
Source File: ExcelUtil.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Excel 2007 using 1900 date base system.Date time is combined by date
 * component and time component. In the 1900 date base system, the lower
 * limit of day component is January 1, 1900, which has serial value 1. The
 * upper-limit is December 31, 9999, which has serial value 2,958,465. The
 * time component of a serial value ranges in value from 0–0.99999999, and
 * represents times from 0:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 P.M.),
 * respectively. Going forward in time, the time component of a serial value
 * increases by 1/86,400 each second.
 * 
 * @param d
 * @param zone
 * @return
 */
public static String getDay( Date d, TimeZone zone )
{
	Calendar currentDay = Calendar.getInstance( zone );
	currentDay.setTime( d );
	int hours = currentDay.get( Calendar.HOUR_OF_DAY );
	int minutes = currentDay.get( Calendar.MINUTE );
	int seconds = currentDay.get( Calendar.SECOND );
	double timeComponent = ( hours * SECONDS_PER_HOUR + minutes
			* SECONDS_PER_MINUTE + seconds )
			/ SECONDS_PER_DAY;
	if ( timeComponent < 0 || timeComponent > 1 )
	{
		logger.log( Level.WARNING, "Invalid time!" );
		timeComponent = 0;
	}
	long currentTimeInMillis = currentDay.getTimeInMillis( );
	int dayComponent = (int) ( ( currentTimeInMillis - BASE_DATE_TIME ) / MILLISECS_PER_DAY );
	if ( dayComponent < 0 || dayComponent > 2958463 )
	{
		logger.log( Level.WARNING, "Invaild day" );
		dayComponent = 0;
	}
	if ( dayComponent <= 59 )
		dayComponent = dayComponent + 1;
	else
		dayComponent = dayComponent + 2;
	double dateTime = dayComponent + timeComponent;
	return Double.toString( dateTime );
}
 
Example 10
Source File: AbstractMDX.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * If the week across month,quarter,year, this week will be divided into 2
 * parts, for example, 2011.11month,week of month 5, this week will be
 * divided into 2011,11,week of month 5 and 2011,12,week of month 0. 
 * So when we do year to date(level week), when visit the 2011.11month,week of month
 * 5, we should also add the extra week, 2011,12,week of month 0
 */
protected void addExtraWeek(List<TimeMember> timeMemberList, Calendar cal, TimeMember srcMember, String[] levels)
{
	int weekStart = 1;
	int week = 1;
	int weekEnd = 1;
	int[] newValues = null;
	TimeMember newMember = null;
	int dayOfWeek = cal.get( Calendar.DAY_OF_WEEK );
	week = cal.get( Calendar.WEEK_OF_MONTH );
	cal.set( Calendar.DAY_OF_WEEK, 1 );
	weekStart = cal.get( Calendar.WEEK_OF_MONTH );

	// if the weekofmonth in a week is not the same, this week must across month,
	// may need add extra week.
	if ( weekStart != week )
	{
		newValues = getValueFromCal( cal, levels );
		newMember = new TimeMember( newValues, levels );

	}
	else
	{
		cal.set( Calendar.DAY_OF_WEEK, 7 );
		weekEnd = cal.get( Calendar.WEEK_OF_MONTH );
		if ( weekEnd != week )
		{
			newValues = getValueFromCal( cal, levels );
			newMember = new TimeMember( newValues, levels );
		}
	}
	if ( newMember != null && !newMember.equals( srcMember ) )
	{
		timeMemberList.add( newMember );
	}
	cal.set( Calendar.DAY_OF_WEEK, dayOfWeek );

}
 
Example 11
Source File: TemporalExpressions.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
public Set<Integer> getMinuteRangeAsSet() {
    Set<Integer> rangeSet = new TreeSet<>();
    if (this.start == this.end) {
        rangeSet.add(this.start);
    } else {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.HOUR_OF_DAY, this.start);
        while (cal.get(Calendar.HOUR_OF_DAY) != this.end) {
            rangeSet.add(cal.get(Calendar.HOUR_OF_DAY));
            cal.add(Calendar.HOUR_OF_DAY, 1);
        }
    }
    return rangeSet;
}
 
Example 12
Source File: BirtDateTime.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected Object getValue( Object[] args, IScriptFunctionContext context ) throws BirtException
{
	if ( existNullValue( args ) )
	{
		return null;
	}
	Calendar current = getCalendar( DataTypeUtil.toDate( args[0] ) );
	int currentWeek = current.get( Calendar.WEEK_OF_YEAR );
	Calendar start = getFiscalYearStateDate( context, args );
	start.set( Calendar.YEAR, current.get( Calendar.YEAR ) );
	int startWeek = start.get( Calendar.WEEK_OF_YEAR );
	if ( currentWeek >= startWeek )
	{
		return currentWeek - startWeek + 1;
	}
	
	// Go to last year to add weeks together
	start.set( Calendar.YEAR, current.get( Calendar.YEAR ) - 1 );
	Calendar lastYearLastWeek = getCalendar( new Date( start.get( Calendar.YEAR ) - 1,
			11,
			31 ) );
	// Last week may return 1 as week of year
	while ( lastYearLastWeek.get( Calendar.WEEK_OF_YEAR ) == 1 )
	{
		lastYearLastWeek.add( Calendar.DAY_OF_MONTH, -1 );
	}
	return lastYearLastWeek.get( Calendar.WEEK_OF_YEAR )
			- start.get( Calendar.WEEK_OF_YEAR ) + 1 + currentWeek;
}
 
Example 13
Source File: UtilDateTime.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
public static int weekNumber(Timestamp input, int startOfWeek) {
    Calendar calendar = Calendar.getInstance();
    calendar.setFirstDayOfWeek(startOfWeek);

    if (startOfWeek == Calendar.MONDAY) {
       calendar.setMinimalDaysInFirstWeek(4);
    } else if (startOfWeek == Calendar.SUNDAY) {
       calendar.setMinimalDaysInFirstWeek(3);
    }

    calendar.setTime(new java.util.Date(input.getTime()));
    return calendar.get(Calendar.WEEK_OF_YEAR);
}
 
Example 14
Source File: SimpleDateFormat.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
/**
 * check whether the i-th item in 2 calendar is in different value.
 *
 * It is supposed to be used only by CLDR survey tool.
 * It is used by intervalFormatByAlgorithm().
 *
 * @param fromCalendar   one calendar
 * @param toCalendar     the other calendar
 * @param items          pattern items
 * @param i              the i-th item in pattern items
 * @exception IllegalArgumentException when there is non-recognized
 *                                     pattern letter
 * @return               true is i-th item in 2 calendar is in different
 *                       value, false otherwise.
 */
private boolean diffCalFieldValue(Calendar fromCalendar,
                                  Calendar toCalendar,
                                  Object[] items,
                                  int i) throws IllegalArgumentException {
    if ( items[i] instanceof String) {
        return false;
    }
    PatternItem item = (PatternItem)items[i];
    char ch = item.type;
    int patternCharIndex = getIndexFromChar(ch);
    if (patternCharIndex == -1) {
        throw new IllegalArgumentException("Illegal pattern character " +
                                           "'" + ch + "' in \"" +
                                           pattern + '"');
    }

    final int field = PATTERN_INDEX_TO_CALENDAR_FIELD[patternCharIndex];
    if (field >= 0) {
        int value = fromCalendar.get(field);
        int value_2 = toCalendar.get(field);
        if ( value != value_2 ) {
            return true;
        }
    }
    return false;
}
 
Example 15
Source File: WeekToDateFunciton.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public List<TimeMember> getResult( TimeMember member )
{
	List timeMembers = new ArrayList<TimeMember>( );
	String[] levelTypes = member.getLevelType( );
	int[] values = member.getMemberValue( );

	Calendar cal = new GregorianCalendar( TimeMemberUtil.getTimeZone( ),
			TimeMemberUtil.getDefaultLocale( ) );
	cal.clear( );
	String baseType = translateToCal( cal, levelTypes, values );

	if ( isCurrent )
	{
		int weekDay = cal.get( Calendar.DAY_OF_WEEK );
		while ( weekDay < 7 )
		{
			cal.add( Calendar.DAY_OF_YEAR, 1 );
			weekDay = cal.get( Calendar.DAY_OF_WEEK );
		}
	}
	
	if ( baseType.equals( WEEK ) )
	{
		timeMembers.add( member );
	}
	else if ( baseType.equals( DAY ) )
	{
		int weekday = cal.get( Calendar.DAY_OF_WEEK );

		int[] tmp;
		Calendar newCal = new GregorianCalendar( TimeMemberUtil.getTimeZone( ),
				TimeMemberUtil.getDefaultLocale( ) );
		for ( int i = 1; i <= weekday; i++ )
		{
			newCal.setTimeInMillis( cal.getTimeInMillis( )
					- ( weekday - i ) * dayTimeInMills );
			tmp = getValueFromCal( newCal, levelTypes );
			TimeMember timeMember = new TimeMember( tmp, levelTypes );
			timeMembers.add( timeMember );
		}
		
	}

	return timeMembers;
}
 
Example 16
Source File: TimeMemberUtil.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public static TimeMember toMember( IDimension timeDimension, Date referenceDate )
{
	ILevel[] levels = timeDimension.getHierarchy( ).getLevels();
	String[] levelType = null;
	levelType = new String[levels.length - 1];
	
	int[] levelValue = new int[levelType.length];
	Calendar cal = getCalendar( referenceDate );
	
	for( int i = 0; i < levelType.length; i++ )
	{
		levelType[i] = levels[i].getLeveType( );
		if( TimeMember.TIME_LEVEL_TYPE_YEAR.equals( levelType[i] ) )
		{
			levelValue[i] = cal.get( Calendar.YEAR );
		}
		else if( TimeMember.TIME_LEVEL_TYPE_QUARTER.equals( levelType[i] ) )
		{
			levelValue[i] = quarter( cal );
		}
		else if( TimeMember.TIME_LEVEL_TYPE_MONTH.equals( levelType[i] ) )
		{
			levelValue[i] = cal.get( Calendar.MONTH ) + 1;
		}
		else if( TimeMember.TIME_LEVEL_TYPE_DAY_OF_MONTH.equals( levelType[i] ) )
		{
			levelValue[i] = cal.get( Calendar.DAY_OF_MONTH );
		}
		else if( TimeMember.TIME_LEVEL_TYPE_DAY_OF_WEEK.equals( levelType[i] ) )
		{
			levelValue[i] = cal.get( Calendar.DAY_OF_WEEK );
		}
		else if( TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR.equals( levelType[i] ) )
		{
			levelValue[i] = cal.get( Calendar.DAY_OF_YEAR );
		}
		else if( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_YEAR.equals( levelType[i] ) )
		{
			levelValue[i] = cal.get( Calendar.WEEK_OF_YEAR );
		}
		else if( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH.equals( levelType[i] ) )
		{
			levelValue[i] = cal.get( Calendar.WEEK_OF_MONTH );
		}
	}
	
	return new TimeMember( levelValue, levelType );
}
 
Example 17
Source File: UtilDateTime.java    From scipio-erp with Apache License 2.0 4 votes vote down vote up
public static int getDayOfYear(Timestamp stamp, TimeZone timeZone, Locale locale) {
    Calendar cal = toCalendar(stamp, timeZone, locale);
    return cal.get(Calendar.DAY_OF_YEAR);
}
 
Example 18
Source File: FocFunctions.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
@ParamCount({ 3, 4 })
public static ValueHolder atFocDate(final FormulaContext ctx, final ValueHolder[] params) {
	boolean[] aux = new boolean[2];
	int yearPart = getRelativePart(ctx, params[0].getObject(0), false, aux);
	boolean yearIsAbs = aux[0];
	int monthPart = getRelativePart(ctx, params[1].getObject(0), false, aux);
	boolean monthIsAbs = aux[0];
	int dayPart = getRelativePart(ctx, params[2].getObject(0), true, aux);
	boolean dayIsAbs = aux[0];
	boolean dayIsUltimo = aux[1];
	DateTime refDate;
	Formatter formatter = ctx.getFormatter();
	if (params.length == 4)
		refDate = formatter.getCopyOfSDTInstance(params[3].getDateTime(0));
	else {
		Object o = ctx.getParam("@FocDate:Bezug");
		if (o instanceof DateTime)
			refDate = formatter.getCopyOfSDTInstance((DateTime) o);
		else
			refDate = formatter.getNewInitializedSDTInstance(new Date(), false, true);
	}
	if (yearIsAbs || monthIsAbs || dayIsAbs) {
		Calendar cal = refDate.toJavaCal();
		int year = yearIsAbs ? yearPart : cal.get(Calendar.YEAR);
		int month = monthIsAbs ? monthPart : cal.get(Calendar.MONTH) + 1;
		int day = dayIsAbs ? dayPart : cal.get(Calendar.DAY_OF_MONTH);
		refDate.setLocalDate(year, month, day);
	}
	if (!yearIsAbs && yearPart != 0)
		refDate.adjustYear(yearPart);
	if (!monthIsAbs && monthPart != 0)
		refDate.adjustMonth(monthPart);
	if (!dayIsAbs && dayPart != 0)
		refDate.adjustDay(dayPart);
	if (dayIsUltimo) {
		refDate.adjustMonth(1);
		refDate.adjustDay(-1);
	}
	refDate.setAnyTime();
	return ValueHolder.valueOf(refDate);
}
 
Example 19
Source File: MCRCalendar.java    From mycore with GNU General Public License v3.0 4 votes vote down vote up
/**
 * This method convert a JulianCalendar date to a general Calendar value.
 * The syntax for the julian input is: <br>
 * <ul>
 * <li> [[[t]t.][m]m.][yyy]y [v. Chr.|n. Chr.]</li>
 * <li> [[[t]t.][m]m.][yyy]y [AD|BC]</li>
 * <li> [-|AD|BC] [[[t]t.][m]m.][yyy]y</li>
 * <li> [[[t]t/][m]m/][yyy]y [AD|BC]</li>
 * <li> [-|AD|BC] [[[t]t/][m]m/][yyy]y</li>
 * <li> y[yyy][-m[m][-t[t]]] [v. Chr.|n. Chr.]</li>
 * <li> y[yyy][-m[m][-t[t]]] [AD|BC]</li>
 * <li> [-|AD|BC] y[yyy][-m[m][-t[t]]]</li>
 * </ul>
 *
 * @param dateString
 *            the date as string.
 * @param last
 *            the value is true if the date should be filled with the
 *            highest value of month or day like 12 or 31 else it fill the
 *            date with the lowest value 1 for month and day.
 *
 * @return the GregorianCalendar date value or null if an error was
 *         occurred.
 * @exception MCRException if parsing has an error
 */
protected static Calendar getCalendarFromJulianDate(String dateString, boolean last) throws MCRException {
    try {
        int[] fields = checkDateStringForJulianCalendar(dateString, last);
        Calendar calendar = new GregorianCalendar();
        calendar.set(fields[0], fields[1], fields[2]);
        if (fields[3] == -1) {
            calendar.set(Calendar.ERA, GregorianCalendar.BC);
        } else {
            calendar.set(Calendar.ERA, GregorianCalendar.AD);
        }
        // correct data
        int julianDay = calendar.get(Calendar.JULIAN_DAY);
        if (fields[0] == 1582 && fields[1] == 9 && fields[2] == 6 && fields[3] == 1) {
            julianDay = 2299162;
        }
        if (fields[0] == 1582 && fields[1] == 9 && fields[2] == 7 && fields[3] == 1) {
            julianDay = 2299163;
        }
        if (fields[0] == 1582 && fields[1] == 9 && fields[2] == 8 && fields[3] == 1) {
            julianDay = 2299164;
        }
        if (fields[0] == 1582 && fields[1] == 9 && fields[2] == 9 && fields[3] == 1) {
            julianDay = 2299165;
        }
        if (fields[0] == 1582 && fields[1] == 9 && fields[2] == 10 && fields[3] == 1) {
            julianDay = 2299166;
        }
        if (fields[0] == 1582 && fields[1] == 9 && fields[2] == 11 && fields[3] == 1) {
            julianDay = 2299167;
        }
        if (fields[0] == 1582 && fields[1] == 9 && fields[2] == 12 && fields[3] == 1) {
            julianDay = 2299168;
        }
        if (fields[0] == 1582 && fields[1] == 9 && fields[2] == 13 && fields[3] == 1) {
            julianDay = 2299169;
        }
        if (fields[0] == 1582 && fields[1] == 9 && fields[2] == 14 && fields[3] == 1) {
            julianDay = 2299170;
        }
        if (fields[0] == 1582 && fields[1] == 9 && fields[2] == 15 && fields[3] == 1) {
            julianDay = 2299171;
        }
        if ((fields[0] > 1582 || (fields[0] == 1582 && fields[1] > 9)
            || (fields[0] == 1582 && fields[1] == 9 && fields[2] > 15))
            && fields[3] == 1) {
            julianDay += 10;
        }
        if ((fields[0] > 1700 || (fields[0] == 1700 && fields[1] >= 2)) && fields[3] == 1) {
            julianDay += 1;
        }
        if ((fields[0] > 1800 || (fields[0] == 1800 && fields[1] >= 2)) && fields[3] == 1) {
            julianDay += 1;
        }
        if ((fields[0] > 1900 || (fields[0] == 1900 && fields[1] >= 2)) && fields[3] == 1) {
            julianDay += 1;
        }
        if ((fields[0] > 2100 || (fields[0] == 2100 && fields[1] >= 2)) && fields[3] == 1) {
            julianDay += 1;
        }
        calendar.set(Calendar.JULIAN_DAY, julianDay);
        return calendar;
    } catch (Exception e) {
        throw new MCRException("The ancient julian date is false.", e);
    }
}
 
Example 20
Source File: UtilDateTime.java    From scipio-erp with Apache License 2.0 2 votes vote down vote up
/**
 * returns a day number in a week for a Timestamp input
 *
 * @param stamp Timestamp date
 * @return A int containing the day number (sunday = 1, saturday = 7)
 */
public static int dayNumber(Timestamp stamp) {
    Calendar tempCal = toCalendar(stamp, TimeZone.getDefault(), Locale.getDefault());
    return tempCal.get(Calendar.DAY_OF_WEEK);
}