本文整理匯總了Java中java.util.Calendar.getMaximum方法的典型用法代碼示例。如果您正苦於以下問題:Java Calendar.getMaximum方法的具體用法?Java Calendar.getMaximum怎麽用?Java Calendar.getMaximum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.Calendar
的用法示例。
在下文中一共展示了Calendar.getMaximum方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: NeedsUpdate
import java.util.Calendar; //導入方法依賴的package包/類
public boolean NeedsUpdate() {
Calendar today = Calendar.getInstance();
_logger.Debug("Today:\n" + today.toString());
_logger.Debug("LastUpdate:\n" + _lastUpdate.toString());
int daysSinceLastUpdate = today.get(Calendar.DAY_OF_YEAR) - _lastUpdate.get(Calendar.DAY_OF_YEAR);
if (daysSinceLastUpdate < 0) {
daysSinceLastUpdate += today.getMaximum(Calendar.DAY_OF_YEAR);
}
if (daysSinceLastUpdate >= _updateInterval) {
_logger.Warn("Account needs update! " + String.valueOf(daysSinceLastUpdate));
return true;
}
_logger.Debug("Account does not need an update!");
return false;
}
示例2: appendTo
import java.util.Calendar; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void appendTo(final StringBuffer buffer, final Calendar calendar) {
int value = calendar.get(Calendar.HOUR_OF_DAY);
if (value == 0) {
value = calendar.getMaximum(Calendar.HOUR_OF_DAY) + 1;
}
mRule.appendTo(buffer, value);
}
示例3: appendTo
import java.util.Calendar; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
public void appendTo(StringBuffer buffer, Calendar calendar) {
int value = calendar.get(Calendar.HOUR_OF_DAY);
if (value == 0) {
value = calendar.getMaximum(Calendar.HOUR_OF_DAY) + 1;
}
mRule.appendTo(buffer, value);
}
示例4: Test4118384
import java.util.Calendar; //導入方法依賴的package包/類
/**
* Make sure maximum for HOUR field is 11, not 12.
*/
public void Test4118384() {
Calendar cal = Calendar.getInstance();
if (cal.getMaximum(HOUR) != 11
|| cal.getLeastMaximum(HOUR) != 11
|| cal.getActualMaximum(HOUR) != 11) {
errln("Fail: maximum of HOUR field should be 11");
}
}
示例5: renderCalendar
import java.util.Calendar; //導入方法依賴的package包/類
/**
* 界麵渲染
*/
private void renderCalendar() {
SimpleDateFormat sdf = new SimpleDateFormat(displayFormat);
txtDate.setText(sdf.format(curDate.getTime()));
selectedDate = curDate.getTime();
if (cells == null) {
cells = new ArrayList<>();
} else {
cells.clear();
}
Calendar calendar = (Calendar) curDate.clone();
calendar.set(Calendar.DAY_OF_MONTH, 1);
int prevDays = calendar.get(Calendar.DAY_OF_WEEK) - 1;
calendar.add(Calendar.DAY_OF_MONTH, -prevDays);
int maxCellCount;
int maxDayNum = calendar.getMaximum(Calendar.DAY_OF_MONTH) + prevDays;
//確定cells的數量
if (maxDayNum > 5 * 7) {
maxCellCount = 6 * 7;
} else if (maxDayNum > 4 * 7) {
maxCellCount = 5 * 7;
} else {
maxCellCount = 4 * 7;
}
while (cells.size() < maxCellCount) {
cells.add(calendar.getTime());
calendar.add(Calendar.DAY_OF_MONTH, 1);
}
calendarAdapter = new CalendarAdapter(getContext(), cells);
calendarGridView.setAdapter(calendarAdapter);
}
示例6: getDaysDifference
import java.util.Calendar; //導入方法依賴的package包/類
private static int getDaysDifference(Calendar before, Calendar after) {
int diff = after.get(Calendar.DAY_OF_YEAR) - before.get(Calendar.DAY_OF_YEAR);
diff = diff + (before.getMaximum(Calendar.DAY_OF_YEAR) * (after.get(Calendar.YEAR) - before.get(Calendar.YEAR)));
return diff;
}
示例7: getWeekDifference
import java.util.Calendar; //導入方法依賴的package包/類
private static int getWeekDifference(Calendar before, Calendar after) {
int diff = after.get(Calendar.WEEK_OF_YEAR) - before.get(Calendar.WEEK_OF_YEAR);
diff = diff + (before.getMaximum(Calendar.WEEK_OF_YEAR) * (after.get(Calendar.YEAR) - before.get(Calendar.YEAR)));
return diff;
}
示例8: addRepeatTask
import java.util.Calendar; //導入方法依賴的package包/類
private void addRepeatTask(Task task){
task.setAlreadyRepeating(true);
Calendar repeatCalender = Calendar.getInstance();
repeatCalender.setTimeInMillis(dateDialog.getDatePicker().getMaxDate());
Calendar taskCalender = task.getTaskDate();
int currentYear = taskCalender.get(Calendar.YEAR);
int maxYear = repeatCalender.get(Calendar.YEAR);
switch (task.getRepeatCategory()){
case 1:
int currentWeek = taskCalender.get(Calendar.WEEK_OF_YEAR);
int maxWeek = repeatCalender.getMaximum(Calendar.WEEK_OF_YEAR);
Log.d(TAG, "Adding weekly repeat task");
while (currentYear < maxYear){
if (currentYear > todayCalender.get(Calendar.YEAR)){
currentWeek = repeatCalender.getMinimum(Calendar.WEEK_OF_YEAR)- 1;
}
taskCalender.set(Calendar.YEAR, currentYear);
while (currentWeek < maxWeek){
taskCalender.set(Calendar.WEEK_OF_YEAR, ++currentWeek);
task.setTaskDate(taskCalender);
presenter.addTask(task, true);
Log.d(TAG, "Adding for week - " + currentWeek);
}
currentYear++;
Log.d(TAG, "Adding for year - " + currentYear);
}
break;
case 2:
int currentMonth = taskCalender.get(Calendar.MONTH);
int maxMonth = repeatCalender.getMaximum(Calendar.MONTH);
Log.d(TAG, "Adding monthly repeat task");
while (currentYear < maxYear){
if (currentYear > todayCalender.get(Calendar.YEAR)){
currentMonth = repeatCalender.getMinimum(Calendar.MONTH) - 1;
}
taskCalender.set(Calendar.YEAR, currentYear);
while (currentMonth < maxMonth){
taskCalender.set(Calendar.MONTH,
++currentMonth);
task.setTaskDate(taskCalender);
presenter.addTask(task, true);
}
currentYear++;
}
break;
case 3:
while (currentYear < maxYear){
Log.d(TAG, "Adding yearly repeat task");
taskCalender.set(Calendar.YEAR,
++currentYear);
task.setTaskDate(taskCalender);
presenter.addTask(task, true);
}
break;
}
}