本文整理汇总了Java中com.ibm.icu.util.Calendar.get方法的典型用法代码示例。如果您正苦于以下问题:Java Calendar.get方法的具体用法?Java Calendar.get怎么用?Java Calendar.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.util.Calendar
的用法示例。
在下文中一共展示了Calendar.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dayDifference
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
/**
* @return the number of days in "until-now"
*/
private static int dayDifference(Calendar until) {
Calendar nowCal = (Calendar)until.clone();
Date nowDate = new Date(System.currentTimeMillis());
nowCal.clear();
nowCal.setTime(nowDate);
int dayDiff = until.get(Calendar.JULIAN_DAY) - nowCal.get(Calendar.JULIAN_DAY);
return dayDiff;
}
示例2: alignDayOfWeek
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
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;
}
示例3: capacityRemaining
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
/** Used to to request the remain capacity available for dateFrom in a TechDataCalenda,
* If the dateFrom (param in) is not in an available TechDataCalendar period, the return value is zero.
*
* @param techDataCalendar The TechDataCalendar cover
* @param dateFrom the date
* @return long capacityRemaining
*/
public static long capacityRemaining(GenericValue techDataCalendar, Timestamp dateFrom) {
GenericValue techDataCalendarWeek = null;
// TODO read TechDataCalendarExcWeek to manage execption week (maybe it's needed to refactor the entity definition
try {
techDataCalendarWeek = techDataCalendar.getRelatedOne("TechDataCalendarWeek", true);
} catch (GenericEntityException e) {
Debug.logError("Pb reading Calendar Week associated with calendar"+e.getMessage(), module);
return 0;
}
// TODO read TechDataCalendarExcDay to manage execption day
Calendar cDateTrav = Calendar.getInstance();
cDateTrav.setTime(dateFrom);
Map<String, Object> position = dayStartCapacityAvailable(techDataCalendarWeek, cDateTrav.get(Calendar.DAY_OF_WEEK));
int moveDay = ((Integer) position.get("moveDay")).intValue();
if (moveDay != 0) return 0;
Time startTime = (Time) position.get("startTime");
Double capacity = (Double) position.get("capacity");
Timestamp startAvailablePeriod = new Timestamp(UtilDateTime.getDayStart(dateFrom).getTime() + startTime.getTime() + cDateTrav.get(Calendar.ZONE_OFFSET) + cDateTrav.get(Calendar.DST_OFFSET));
if (dateFrom.before(startAvailablePeriod)) return 0;
Timestamp endAvailablePeriod = new Timestamp(startAvailablePeriod.getTime()+capacity.longValue());
if (dateFrom.after(endAvailablePeriod)) return 0;
return endAvailablePeriod.getTime() - dateFrom.getTime();
}
示例4: includesDate
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
@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;
}
示例5: getPatterns
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
/**
* @internal
* @deprecated This API is ICU internal only.
*/
@Deprecated
public String getPatterns(Calendar fromCalendar,
Calendar toCalendar,
Output<String> part2) {
// First, find the largest different calendar field.
int field;
if ( fromCalendar.get(Calendar.ERA) != toCalendar.get(Calendar.ERA) ) {
field = Calendar.ERA;
} else if ( fromCalendar.get(Calendar.YEAR) !=
toCalendar.get(Calendar.YEAR) ) {
field = Calendar.YEAR;
} else if ( fromCalendar.get(Calendar.MONTH) !=
toCalendar.get(Calendar.MONTH) ) {
field = Calendar.MONTH;
} else if ( fromCalendar.get(Calendar.DATE) !=
toCalendar.get(Calendar.DATE) ) {
field = Calendar.DATE;
} else if ( fromCalendar.get(Calendar.AM_PM) !=
toCalendar.get(Calendar.AM_PM) ) {
field = Calendar.AM_PM;
} else if ( fromCalendar.get(Calendar.HOUR) !=
toCalendar.get(Calendar.HOUR) ) {
field = Calendar.HOUR;
} else if ( fromCalendar.get(Calendar.MINUTE) !=
toCalendar.get(Calendar.MINUTE) ) {
field = Calendar.MINUTE;
} else if ( fromCalendar.get(Calendar.SECOND) !=
toCalendar.get(Calendar.SECOND) ) {
field = Calendar.SECOND;
} else {
return null;
}
PatternInfo intervalPattern = fIntervalPatterns.get(
DateIntervalInfo.CALENDAR_FIELD_TO_PATTERN_LETTER[field]);
part2.value = intervalPattern.getSecondPart();
return intervalPattern.getFirstPart();
}
示例6: initializeDefaultCenturyStart
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
private void initializeDefaultCenturyStart(long baseTime) {
defaultCenturyBase = baseTime;
// clone to avoid messing up date stored in calendar object
// when this method is called while parsing
Calendar tmpCal = (Calendar)calendar.clone();
tmpCal.setTimeInMillis(baseTime);
tmpCal.add(Calendar.YEAR, -80);
defaultCenturyStart = tmpCal.getTime();
defaultCenturyStartYear = tmpCal.get(Calendar.YEAR);
}
示例7: diffCalFieldValue
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
/**
* 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;
}
示例8: getCount
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
@Override
public int getCount() {
Calendar endDate = mController.getEndDate();
Calendar startDate = mController.getStartDate();
int endMonth = endDate.get(Calendar.YEAR) * MONTHS_IN_YEAR + endDate.get(Calendar.MONTH);
int startMonth = startDate.get(Calendar.YEAR) * MONTHS_IN_YEAR + startDate.get(Calendar.MONTH);
return ((mController.getMaxYear() - mController.getMinYear()) + 1) * MONTHS_IN_YEAR;
}
示例9: adjustDayInMonthIfNeeded
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
private void adjustDayInMonthIfNeeded(Calendar calendar) {
int day = calendar.get(Calendar.DAY_OF_MONTH);
int daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
if (day > daysInMonth) {
calendar.set(Calendar.DAY_OF_MONTH, daysInMonth);
}
setToNearestDate(calendar);
}
示例10: startNextDay
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
/** Used to move in a TechDataCalenda, produce the Timestamp for the begining of the next day available and its associated capacity.
* If the dateFrom (param in) is not in an available TechDataCalendar period, the return value is the next day available
*
* @param techDataCalendar The TechDataCalendar cover
* @param dateFrom the date
* @return a map with Timestamp dateTo, Double nextCapacity
*/
public static Map<String, Object> startNextDay(GenericValue techDataCalendar, Timestamp dateFrom) {
Map<String, Object> result = FastMap.newInstance();
Timestamp dateTo = null;
GenericValue techDataCalendarWeek = null;
// TODO read TechDataCalendarExcWeek to manage execption week (maybe it's needed to refactor the entity definition
try {
techDataCalendarWeek = techDataCalendar.getRelatedOne("TechDataCalendarWeek", true);
} catch (GenericEntityException e) {
Debug.logError("Pb reading Calendar Week associated with calendar"+e.getMessage(), module);
return ServiceUtil.returnError("Pb reading Calendar Week associated with calendar");
}
// TODO read TechDataCalendarExcDay to manage execption day
Calendar cDateTrav = Calendar.getInstance();
cDateTrav.setTime(dateFrom);
Map<String, Object> position = dayStartCapacityAvailable(techDataCalendarWeek, cDateTrav.get(Calendar.DAY_OF_WEEK));
Time startTime = (Time) position.get("startTime");
int moveDay = ((Integer) position.get("moveDay")).intValue();
dateTo = (moveDay == 0) ? dateFrom : UtilDateTime.getDayStart(dateFrom,moveDay);
Timestamp startAvailablePeriod = new Timestamp(UtilDateTime.getDayStart(dateTo).getTime() + startTime.getTime() + cDateTrav.get(Calendar.ZONE_OFFSET) + cDateTrav.get(Calendar.DST_OFFSET));
if (dateTo.before(startAvailablePeriod)) {
dateTo = startAvailablePeriod;
}
else {
dateTo = UtilDateTime.getNextDayStart(dateTo);
cDateTrav.setTime(dateTo);
position = dayStartCapacityAvailable(techDataCalendarWeek, cDateTrav.get(Calendar.DAY_OF_WEEK));
startTime = (Time) position.get("startTime");
moveDay = ((Integer) position.get("moveDay")).intValue();
if (moveDay != 0) dateTo = UtilDateTime.getDayStart(dateTo,moveDay);
dateTo.setTime(dateTo.getTime() + startTime.getTime() + cDateTrav.get(Calendar.ZONE_OFFSET) + cDateTrav.get(Calendar.DST_OFFSET));
}
result.put("dateTo",dateTo);
result.put("nextCapacity",position.get("capacity"));
return result;
}
示例11: endPreviousDay
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
/** Used to move in a TechDataCalenda, produce the Timestamp for the end of the previous day available and its associated capacity.
* If the dateFrom (param in) is not in an available TechDataCalendar period, the return value is the previous day available
*
* @param techDataCalendar The TechDataCalendar cover
* @param dateFrom the date
* @return a map with Timestamp dateTo, Double previousCapacity
*/
public static Map<String, Object> endPreviousDay(GenericValue techDataCalendar, Timestamp dateFrom) {
Map<String, Object> result = FastMap.newInstance();
Timestamp dateTo = null;
GenericValue techDataCalendarWeek = null;
// TODO read TechDataCalendarExcWeek to manage exception week (maybe it's needed to refactor the entity definition
try {
techDataCalendarWeek = techDataCalendar.getRelatedOne("TechDataCalendarWeek", true);
} catch (GenericEntityException e) {
Debug.logError("Pb reading Calendar Week associated with calendar"+e.getMessage(), module);
return ServiceUtil.returnError("Pb reading Calendar Week associated with calendar");
}
// TODO read TechDataCalendarExcDay to manage execption day
Calendar cDateTrav = Calendar.getInstance();
cDateTrav.setTime(dateFrom);
Map<String, Object> position = dayEndCapacityAvailable(techDataCalendarWeek, cDateTrav.get(Calendar.DAY_OF_WEEK));
Time startTime = (Time) position.get("startTime");
int moveDay = ((Integer) position.get("moveDay")).intValue();
Double capacity = (Double) position.get("capacity");
dateTo = (moveDay == 0) ? dateFrom : UtilDateTime.getDayEnd(dateFrom, Long.valueOf(moveDay));
Timestamp endAvailablePeriod = new Timestamp(UtilDateTime.getDayStart(dateTo).getTime() + startTime.getTime() + capacity.longValue() + cDateTrav.get(Calendar.ZONE_OFFSET) + cDateTrav.get(Calendar.DST_OFFSET));
if (dateTo.after(endAvailablePeriod)) {
dateTo = endAvailablePeriod;
}
else {
dateTo = UtilDateTime.getDayStart(dateTo, -1);
cDateTrav.setTime(dateTo);
position = dayEndCapacityAvailable(techDataCalendarWeek, cDateTrav.get(Calendar.DAY_OF_WEEK));
startTime = (Time) position.get("startTime");
moveDay = ((Integer) position.get("moveDay")).intValue();
capacity = (Double) position.get("capacity");
if (moveDay != 0) dateTo = UtilDateTime.getDayStart(dateTo,moveDay);
dateTo.setTime(dateTo.getTime() + startTime.getTime() + capacity.longValue() + cDateTrav.get(Calendar.ZONE_OFFSET) + cDateTrav.get(Calendar.DST_OFFSET));
}
result.put("dateTo",dateTo);
result.put("previousCapacity",position.get("capacity"));
return result;
}
示例12: getLastDayOfWeek
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
/** Returns the last day of the week for the specified locale.
* @param locale
* @return The last day of the week for the specified locale
*/
public static int getLastDayOfWeek(Locale locale) {
Calendar tempCal = Calendar.getInstance(locale);
tempCal.set(Calendar.DAY_OF_WEEK, tempCal.getFirstDayOfWeek());
tempCal.roll(Calendar.DAY_OF_WEEK, -1);
return tempCal.get(Calendar.DAY_OF_WEEK);
}
示例13: weekNumber
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
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);
}
示例14: sameDay
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
private boolean sameDay(int day, Calendar today) {
return mYear == today.get(Calendar.YEAR) &&
mMonth == today.get(Calendar.MONTH) &&
day == today.get(Calendar.DAY_OF_MONTH);
}
示例15: CalendarDay
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public CalendarDay(Calendar calendar) {
year = calendar.get(Calendar.YEAR);
month = calendar.get(Calendar.MONTH);
day = calendar.get(Calendar.DAY_OF_MONTH);
}