当前位置: 首页>>代码示例>>Java>>正文


Java DateTime类代码示例

本文整理汇总了Java中hirondelle.date4j.DateTime的典型用法代码示例。如果您正苦于以下问题:Java DateTime类的具体用法?Java DateTime怎么用?Java DateTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DateTime类属于hirondelle.date4j包,在下文中一共展示了DateTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleMothChange

import hirondelle.date4j.DateTime; //导入依赖的package包/类
private void handleMothChange(DateTime curMonth) {
    // API supports 10 context codes in each call
    int requiredSplits = (int) Math.ceil((double) globalContextCodes.size() / 10);
    int j = 0;
    for (int i = 0; i < requiredSplits; i++) {
        // The context codes for a call
        ArrayList<String> contextCodeSingleCall = new ArrayList<>();
        for (; contextCodeSingleCall.size() <= 9 && j < globalContextCodes.size(); j++) {
            contextCodeSingleCall.add(globalContextCodes.get(j));
        }

        if (!calendar.loaded(curMonth.getYear(), curMonth.getMonth(), "event")) {
            getEvents(curMonth.getYear(), curMonth.getMonth(), contextCodeSingleCall, UUID.randomUUID());
        }

        if (!calendar.loaded(curMonth.getYear(), curMonth.getMonth(), "assignment")) {
            getAssignments(curMonth.getYear(), curMonth.getMonth(), contextCodeSingleCall, UUID.randomUUID());
        }
    }
}
 
开发者ID:andrmos,项目名称:imber,代码行数:21,代码来源:CalendarFragment.java

示例2: getEvent

import hirondelle.date4j.DateTime; //导入依赖的package包/类
/**
 * Formatting string representation for a course
 * @param i
 * @return
 */
private String getEvent(int i) {
    DateTime start = agendas.get(i).getStartDate();
    DateTime end = agendas.get(i).getEndDate();

    String summary = agendas.get(i).getTrimmedTitle() + " ";

    //Gives time two digit representation
    summary += start.getDay() + ".";
    summary += start.getMonth() + " ";
    summary += String.format("%02d",start.getHour()) + ":";
    summary += String.format("%02d",start.getMinute()) + "-";
    summary += String.format("%02d",end.getHour()) + ":";
    summary += String.format("%02d",end.getMinute());

    return summary;
}
 
开发者ID:andrmos,项目名称:imber,代码行数:22,代码来源:CourseRecyclerViewAdapter.java

示例3: createServingsForDay

import hirondelle.date4j.DateTime; //导入依赖的package包/类
@DebugLog
private void createServingsForDay(List<Food> allFoods, DateTime current) {
    ActiveAndroid.beginTransaction();

    try {
        final Day day = new Day(current);
        day.save();

        for (Food food : allFoods) {
            final int recommendedServings = food.getRecommendedServings();
            final int numServings = taskParams.generateRandomData() ? random.nextInt(recommendedServings + 1) : recommendedServings;

            if (numServings > 0) {
                Servings.createServingsIfDoesNotExist(day, food, numServings);
            }
        }

        ActiveAndroid.setTransactionSuccessful();
    } finally {
        ActiveAndroid.endTransaction();
    }
}
 
开发者ID:nutritionfactsorg,项目名称:daily-dozen-android,代码行数:23,代码来源:GenerateDataTask.java

示例4: setSelectedDates

import hirondelle.date4j.DateTime; //导入依赖的package包/类
public void setSelectedDates(Date fromDate, Date toDate) {
    // Ensure fromDate is before toDate
    if (fromDate == null || toDate == null || fromDate.after(toDate)) {
        return;
    }

    clearSelectedDates();

    DateTime fromDateTime = CalendarHelper.convertDateToDateTime(fromDate);
    DateTime toDateTime = CalendarHelper.convertDateToDateTime(toDate);

    DateTime dateTime = fromDateTime;
    while (dateTime.lt(toDateTime)) {
        selectedDate = dateTime;
    }

}
 
开发者ID:maheswaranapk,项目名称:Andorid-Material-Drop-Down-Date-Picker,代码行数:18,代码来源:CalendarFragment.java

示例5: getDaysOfWeek

import hirondelle.date4j.DateTime; //导入依赖的package包/类
protected ArrayList<String> getDaysOfWeek() {
    ArrayList<String> list = new ArrayList<String>();

    SimpleDateFormat fmt = new SimpleDateFormat("EEE", Locale.getDefault());

    // 17 Feb 2013 is Sunday
    DateTime sunday = new DateTime(2013, 2, 17, 0, 0, 0, 0);
    DateTime nextDay = sunday.plusDays(startDayOfWeek - SUNDAY);

    for (int i = 0; i < 7; i++) {
        Date date = CalendarHelper.convertDateTimeToDate(nextDay);
        list.add(fmt.format(date).toUpperCase());
        nextDay = nextDay.plusDays(1);
    }

    return list;
}
 
开发者ID:maheswaranapk,项目名称:Andorid-Material-Drop-Down-Date-Picker,代码行数:18,代码来源:CalendarFragment.java

示例6: populateFromCaldroidData

import hirondelle.date4j.DateTime; //导入依赖的package包/类
/**
 * Retrieve internal parameters from caldroid data
 */
@SuppressWarnings("unchecked")
private void populateFromCaldroidData() {
	selectedDates = (ArrayList<DateTime>) caldroidData.get(CaldroidFragment.SELECTED_DATES);
	if (selectedDates != null) {
		selectedDatesMap.clear();
		for (DateTime dateTime : selectedDates) {
			selectedDatesMap.put(dateTime, 1);
		}
	}

	minDateTime = (DateTime) caldroidData.get(CaldroidFragment._MIN_DATE_TIME);
	maxDateTime = (DateTime) caldroidData.get(CaldroidFragment._MAX_DATE_TIME);
	startDayOfWeek = (Integer) caldroidData.get(CaldroidFragment.START_DAY_OF_WEEK);
	sixWeeksInCalendar = (Boolean) caldroidData.get(CaldroidFragment.SIX_WEEKS_IN_CALENDAR);

	this.datetimeList = CalendarHelper.getFullWeeks(this.month, this.year,startDayOfWeek, sixWeeksInCalendar);
}
 
开发者ID:FrancescoDesogus,项目名称:IUM_Project_SwimDroid,代码行数:21,代码来源:CaldroidGridAdapter.java

示例7: setSelectedDates

import hirondelle.date4j.DateTime; //导入依赖的package包/类
/**
 * Select the dates from fromDate to toDate. By default the background color
 * is holo_blue_light, and the text color is black. You can customize the
 * background by changing CaldroidFragment.selectedBackgroundDrawable, and
 * change the text color CaldroidFragment.selectedTextColor before call this
 * method. This method does not refresh view, need to call refreshView()
 * 
 * @param fromDate
 * @param toDate
 */
public void setSelectedDates(Date fromDate, Date toDate) {
	// Ensure fromDate is before toDate
	if (fromDate == null || toDate == null || fromDate.after(toDate)) {
		return;
	}

	selectedDates.clear();

	DateTime fromDateTime = CalendarHelper.convertDateToDateTime(fromDate);
	DateTime toDateTime = CalendarHelper.convertDateToDateTime(toDate);

	DateTime dateTime = fromDateTime;
	while (dateTime.lt(toDateTime)) {
		selectedDates.add(dateTime);
		dateTime = dateTime.plusDays(1);
	}
	selectedDates.add(toDateTime);
}
 
开发者ID:iSCAU,项目名称:iSCAU-Android,代码行数:29,代码来源:CaldroidFragment.java

示例8: onLoadFinished

import hirondelle.date4j.DateTime; //导入依赖的package包/类
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    // we use a DateTime here as it is native to Caldroid
    HashMap<DateTime, Integer> backgrounds = new HashMap<DateTime, Integer>();

    while (data.moveToNext()) {
        int worn = data.getInt(data.getColumnIndexOrThrow(LensLogContract.DaysWorn.WASWORN));
        DateTime utcDateTime = DateTime.forInstant(data.getLong(data.getColumnIndexOrThrow(LensLogContract.DaysWorn.DATETIME)), TimeZone.getTimeZone("UTC"));
        if (worn == 1) {
            // the lens was worn
            backgrounds.put(utcDateTime, R.color.CalendarBackgroundGreen);
        } else {
            // the lens was explicitly not worn
            backgrounds.put(utcDateTime, R.color.CalendarBackgroundRed);
        }

    }

    // now update the calendar view
    updateCalendarBackgrounds(backgrounds);
}
 
开发者ID:istvank,项目名称:LensLog,代码行数:22,代码来源:CalendarFragment.java

示例9: updateDateAndTimePickers

import hirondelle.date4j.DateTime; //导入依赖的package包/类
private void updateDateAndTimePickers(DateTime dateTime) {
	time.setCurrentHour(dateTime.getHour());
	time.setCurrentMinute(dateTime.getMinute());
	if (pickersAreInitialized) {
		date.updateDate(dateTime.getYear(), dateTime.getMonth() - 1, dateTime.getDay());
	} else {
		time.setOnTimeChangedListener(this);
		date.init(dateTime.getYear(), dateTime.getMonth() - 1, dateTime.getDay(), this);
		pickersAreInitialized = true;
		// manually set the variables once:
		selectedHour = dateTime.getHour();
		selectedMinute = dateTime.getMinute();
		selectedYear = dateTime.getYear();
		selectedMonth = dateTime.getMonth() - 1;
		selectedDay = dateTime.getDay();
		setWeekday();
	}
}
 
开发者ID:mathisdt,项目名称:trackworktime,代码行数:19,代码来源:EventEditActivity.java

示例10: getDateItemLongClickListener

import hirondelle.date4j.DateTime; //导入依赖的package包/类
/**
 * Callback to listener when date is valid (not disable, not outside of
 * min/max date)
 * 
 * @return
 */
private OnItemLongClickListener getDateItemLongClickListener() {
	dateItemLongClickListener = new OnItemLongClickListener() {
		@Override
		public boolean onItemLongClick(AdapterView<?> parent, View view,
				int position, long id) {

			DateTime dateTime = dateInMonthsList.get(position);

			if (caldroidListener != null) {
				if ((minDateTime != null && dateTime.lt(minDateTime))
						|| (maxDateTime != null && dateTime.gt(maxDateTime))
						|| (disableDates != null && disableDates
								.indexOf(dateTime) != -1)) {
					return false;
				}
				Date date = CalendarHelper.convertDateTimeToDate(dateTime);
				caldroidListener.onLongClickDate(date, view);
			}

			return true;
		}
	};

	return dateItemLongClickListener;
}
 
开发者ID:iSCAU,项目名称:iSCAU-Android,代码行数:32,代码来源:CaldroidFragment.java

示例11: createSumsPerMonthCsv

import hirondelle.date4j.DateTime; //导入依赖的package包/类
public String createSumsPerMonthCsv(Map<DateTime, Map<Task, TimeSum>> sumsPerRange) {
	List<TimeSumsHolder> prepared = new LinkedList<TimeSumsHolder>();
	for (Entry<DateTime, Map<Task, TimeSum>> rangeEntry : sumsPerRange.entrySet()) {
		String month = DateTimeUtil.dateTimeToDateString(rangeEntry.getKey());
		Map<Task, TimeSum> sums = rangeEntry.getValue();
		for (Entry<Task, TimeSum> entry : sums.entrySet()) {
			String task = "";
			if (entry.getKey() != null) {
				task = entry.getKey().getName() + " (ID=" + entry.getKey().getId() + ")";
			}
			prepared.add(new TimeSumsHolder(month, null, task, entry.getValue()));
		}
	}
	Collections.sort(prepared);

	return createCsv(prepared, new String[] { "month", "task", "spent" }, sumsPerRangeProcessors);
}
 
开发者ID:mathisdt,项目名称:trackworktime,代码行数:18,代码来源:CsvGenerator.java

示例12: getWeekDayLongName

import hirondelle.date4j.DateTime; //导入依赖的package包/类
/**
 * Get the complete name of the week day indicated by the given date.
 */
public static String getWeekDayLongName(DateTime date) {
	WeekDayEnum weekDay = WeekDayEnum.getByValue(date.getWeekDay());
	switch (weekDay) {
		case MONDAY:
			return Basics.getInstance().getContext().getText(R.string.mondayLong).toString();
		case TUESDAY:
			return Basics.getInstance().getContext().getText(R.string.tuesdayLong).toString();
		case WEDNESDAY:
			return Basics.getInstance().getContext().getText(R.string.wednesdayLong).toString();
		case THURSDAY:
			return Basics.getInstance().getContext().getText(R.string.thursdayLong).toString();
		case FRIDAY:
			return Basics.getInstance().getContext().getText(R.string.fridayLong).toString();
		case SATURDAY:
			return Basics.getInstance().getContext().getText(R.string.saturdayLong).toString();
		case SUNDAY:
			return Basics.getInstance().getContext().getText(R.string.sundayLong).toString();
		default:
			throw new IllegalStateException("unknown weekday");
	}
}
 
开发者ID:mathisdt,项目名称:trackworktime,代码行数:25,代码来源:WeekDayHelper.java

示例13: insertDefaultWorkTimes

import hirondelle.date4j.DateTime; //导入依赖的package包/类
public void insertDefaultWorkTimes(DateTime from, DateTime to, Integer taskId, String text) {
	DateTime running = from.getStartOfDay();
	DateTime target = to.getStartOfDay();
	while (running.lteq(target)) {
		// clock-in at start of day (00:00)

		WeekDayEnum weekDay = WeekDayEnum.getByValue(running.getWeekDay());
		int workDuration = getNormalWorkDurationFor(weekDay);
		if (workDuration > 0) {
			createEvent(running, taskId, TypeEnum.CLOCK_IN, text);
			DateTime clockOutTime = running.plus(0, 0, 0, 0, workDuration, 0, 0, DayOverflow.Spillover);
			if (isAutoPauseApplicable(clockOutTime)) {
				int pauseDuration = getAutoPauseDuration(clockOutTime);
				clockOutTime = clockOutTime.plus(0, 0, 0, 0, pauseDuration, 0, 0, DayOverflow.Spillover);
			}
			createEvent(clockOutTime, null, TypeEnum.CLOCK_OUT, null);
		}

		running = running.plusDays(1);
	}
}
 
开发者ID:mathisdt,项目名称:trackworktime,代码行数:22,代码来源:TimerManager.java

示例14: getFlexiBalanceAtWeekStart

import hirondelle.date4j.DateTime; //导入依赖的package包/类
/**
 * Get the flexi-time balance which is effective at the given week start.
 */
public TimeSum getFlexiBalanceAtWeekStart(DateTime weekStart) {
	TimeSum ret = new TimeSum();
	String startValueString = preferences.getString(Key.FLEXI_TIME_START_VALUE.getName(), "0:00");
	String targetWorkTimeString = preferences.getString(Key.FLEXI_TIME_TARGET.getName(), "0:00");
	TimeSum startValue = parseHoursMinutesString(startValueString);
	TimeSum targetWorkTime = parseHoursMinutesString(targetWorkTimeString);
	ret.addOrSubstract(startValue);

	DateTime upTo = weekStart.minusDays(1);
	List<Week> weeksToCount = dao.getWeeksUpTo(DateTimeUtil.dateTimeToString(upTo));

	for (Week week : weeksToCount) {
		Integer weekWorkedMinutes = week.getSum();
		if (weekWorkedMinutes != null) {
			// add the actual work time
			ret.add(0, weekWorkedMinutes);
			// substract the target work time
			ret.substract(0, targetWorkTime.getAsMinutes());
		} else {
			Logger.warn("week {0} (starting at {1}) has a null sum", week.getId(), week.getStart());
		}
	}

	return ret;
}
 
开发者ID:mathisdt,项目名称:trackworktime,代码行数:29,代码来源:TimerManager.java

示例15: checkModifyAnimations

import hirondelle.date4j.DateTime; //导入依赖的package包/类
/**
 * Funzione che controlla se ci devono essere animazioni relative alla barra degli eventi nella cella
 * @param dateTime La data correntemente controllata
 */
public void checkModifyAnimations(DateTime dateTime){
	
	//se la data dei nuovi eventi non � null ed � proprio quella correntemente controllata
	if((newEventDate != null ) && (newEventDate.equals(dateTime))){			
		eventBar.setVisibility(View.INVISIBLE); //setto la barra invisibile
		Animation animFadeIn = AnimationUtils.loadAnimation(mContext, R.anim.fade_in); //carico l'animazione di fade in
		eventBar.startAnimation(animFadeIn); //avvio l'animazione
		eventBar.setVisibility(View.VISIBLE); //e risetto la barra visibile per il post animazione
	}
	//se la data degli eventi rimossi non � null ed � proprio quella correntemente controllata
	else if((removedEventDate != null ) && (removedEventDate.equals(dateTime))){
		eventBar.setVisibility(View.VISIBLE); //setto la barra visibile
		Animation animFadeOut = AnimationUtils.loadAnimation(mContext, R.anim.fade_out); //carico l'animazione di fade out
		eventBar.startAnimation(animFadeOut); //avvio l'animazione
		eventBar.setVisibility(View.INVISIBLE); //e risetto la barra invisibile per il post animazione
	}	
}
 
开发者ID:FrancescoDesogus,项目名称:IUM_Project_SwimDroid,代码行数:22,代码来源:CalendarCustomAdapter.java


注:本文中的hirondelle.date4j.DateTime类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。