本文整理汇总了Java中org.dmfs.rfc5545.DateTime.isFloating方法的典型用法代码示例。如果您正苦于以下问题:Java DateTime.isFloating方法的具体用法?Java DateTime.isFloating怎么用?Java DateTime.isFloating使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dmfs.rfc5545.DateTime
的用法示例。
在下文中一共展示了DateTime.isFloating方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUntil
import org.dmfs.rfc5545.DateTime; //导入方法依赖的package包/类
/**
* Set the latest possible date of an instance. This will remove any COUNT rule if present. If the time zone of <code>until</code> is not UTC and until is
* not floating it's automatically converted to UTC.
*
* @param until
* The UNTIL part of this rule or <code>null</code> to let the instances recur forever.
*/
public void setUntil(DateTime until)
{
if (until == null)
{
mParts.remove(Part.UNTIL);
mParts.remove(Part.COUNT);
}
else
{
if ((!until.isFloating() && !DateTime.UTC.equals(until.getTimeZone())) || !mCalendarMetrics.equals(
until.getCalendarMetrics()))
{
mParts.put(Part.UNTIL, new DateTime(mCalendarMetrics, DateTime.UTC, until.getTimestamp()));
}
else
{
mParts.put(Part.UNTIL, until);
}
mParts.remove(Part.COUNT);
}
}
示例2: toTime
import org.dmfs.rfc5545.DateTime; //导入方法依赖的package包/类
/**
* {@link Time} will eventually be replaced with {@link DateTime} in the project.
* This conversion function is only needed in the transition period.
*/
@VisibleForTesting
Time toTime(DateTime dateTime)
{
if (dateTime.isFloating() && !dateTime.isAllDay())
{
throw new IllegalArgumentException("Cannot support floating DateTime that is not all-day, can't represent it with Time");
}
// Time always needs a TimeZone (default ctor falls back to TimeZone.getDefault())
String timeZoneId = dateTime.getTimeZone() == null ? "UTC" : dateTime.getTimeZone().getID();
Time time = new Time(timeZoneId);
time.set(dateTime.getTimestamp());
// TODO Would using time.set(monthDay, month, year) be better?
if (dateTime.isAllDay())
{
time.allDay = true;
// This is needed as per time.allDay docs:
time.hour = 0;
time.minute = 0;
time.second = 0;
}
return time;
}
示例3: TimeRange
import org.dmfs.rfc5545.DateTime; //导入方法依赖的package包/类
/**
* Create a {@link TimeRange} filter for the given start and end date.
*
* @param start
* The {@link DateTime} of the start of the range or <code>null</code> for an open range in the past.
* @param end
* The {@link DateTime} of the end of the range or <code>null</code> for an open range in the future.
*/
public TimeRange(DateTime start, DateTime end)
{
if (start == null && end == null)
{
throw new IllegalArgumentException("at least one of start or end must be given");
}
if (end != null && start != null && !end.after(start))
{
throw new IllegalArgumentException("start must be before end");
}
if (start != null)
{
if (start.isFloating())
{
throw new IllegalArgumentException("start date must have absolute time");
}
this.start = new DateTime(DateTime.GREGORIAN_CALENDAR_SCALE, DateTime.UTC, start);
}
else
{
this.start = null;
}
if (end != null)
{
if (end.isFloating())
{
throw new IllegalArgumentException("end date must have absolute time");
}
this.end = new DateTime(DateTime.GREGORIAN_CALENDAR_SCALE, DateTime.UTC, end);
}
else
{
this.end = null;
}
}
示例4: RecurrenceRuleIterator
import org.dmfs.rfc5545.DateTime; //导入方法依赖的package包/类
/**
* Creates a new {@link RecurrenceRuleIterator} that gets its input from <code>ruleIterator</code>.
*
* @param ruleIterator
* The last {@link RuleIterator} in the chain of iterators.
* @param start
* The first instance to iterate.
*/
RecurrenceRuleIterator(RuleIterator ruleIterator, DateTime start, CalendarMetrics calendarMetrics)
{
mRuleIterator = ruleIterator;
mAllDay = start.isAllDay();
mCalendarMetrics = calendarMetrics;
mTimeZone = start.isFloating() ? null : start.getTimeZone();
fetchNextInstance();
}
示例5: UntilLimiter
import org.dmfs.rfc5545.DateTime; //导入方法依赖的package包/类
/**
* Create a new limiter for the UNTIL part.
*
* @param rule
* The {@link RecurrenceRule} to filter.
* @param previous
* The previous filter instance.
* @param start
* The first instance. This is used to determine if the iterated instances are floating or not.
*/
public UntilLimiter(RecurrenceRule rule, RuleIterator previous, CalendarMetrics calendarMetrics, TimeZone startTimezone)
{
super(previous);
DateTime until = rule.getUntil();
if (!until.isFloating())
{
until = until.shiftTimeZone(startTimezone);
}
mUntil = until.getInstance();
}
示例6: isEquivalentDateTimeAndTime
import org.dmfs.rfc5545.DateTime; //导入方法依赖的package包/类
/**
* Contains the definition/requirement of when a {@link DateTime} and {@link Time} is considered equivalent in this project.
*/
private boolean isEquivalentDateTimeAndTime(DateTime dateTime, Time time)
{
// android.text.Time doesn't seem to store in millis precision, there is a 1000 multiplier used there internally
// when calculating millis, so we can only compare in this precision:
boolean millisMatch =
dateTime.getTimestamp() / 1000
==
time.toMillis(false) / 1000;
boolean yearMatch = dateTime.getYear() == time.year;
boolean monthMatch = dateTime.getMonth() == time.month;
boolean dayMatch = dateTime.getDayOfMonth() == time.monthDay;
boolean hourMatch = dateTime.getHours() == time.hour;
boolean minuteMatch = dateTime.getMinutes() == time.minute;
boolean secondsMatch = dateTime.getSeconds() == time.second;
boolean allDaysMatch = time.allDay == dateTime.isAllDay();
boolean timeZoneMatch =
(dateTime.isFloating() && dateTime.isAllDay() && time.timezone.equals("UTC"))
||
// This is the regular case with non-floating DateTime
(dateTime.getTimeZone() != null && time.timezone.equals(dateTime.getTimeZone().getID()));
return millisMatch
&& yearMatch
&& monthMatch
&& dayMatch
&& hourMatch
&& minuteMatch
&& secondsMatch
&& allDaysMatch
&& timeZoneMatch;
}
示例7: getFrom
import org.dmfs.rfc5545.DateTime; //导入方法依赖的package包/类
@Override
public DateTime[] getFrom(ContentValues values)
{
String datetimeList = values.getAsString(mDateTimeListFieldName);
if (datetimeList == null)
{
// no list, return null
return null;
}
// create a new TimeZone for the given time zone string
String timezoneString = mTimeZoneFieldName == null ? null : values.getAsString(mTimeZoneFieldName);
TimeZone timeZone = timezoneString == null ? null : TimeZone.getTimeZone(timezoneString);
String[] datetimes = SEPARATOR_PATTERN.split(datetimeList);
DateTime[] result = new DateTime[datetimes.length];
for (int i = 0, count = datetimes.length; i < count; ++i)
{
DateTime value = DateTime.parse(timeZone, datetimes[i]);
if (!value.isAllDay() && value.isFloating())
{
throw new IllegalArgumentException("DateTime values must not be floating, unless they are all-day.");
}
result[i] = value;
if (i > 0 && result[0].isAllDay() != value.isAllDay())
{
throw new IllegalArgumentException("DateTime values must all be of the same type.");
}
}
return result;
}
示例8: setIn
import org.dmfs.rfc5545.DateTime; //导入方法依赖的package包/类
@Override
public void setIn(ContentValues values, DateTime[] value)
{
if (value != null && value.length > 0)
{
try
{
// Note: we only store the datetime strings, not the timezone
StringBuilder result = new StringBuilder(value.length * 17 /* this is the maximum length */);
boolean first = true;
for (DateTime datetime : value)
{
if (first)
{
first = false;
}
else
{
result.append(',');
}
DateTime outvalue = datetime.isFloating() ? datetime : datetime.shiftTimeZone(DateTime.UTC);
outvalue.writeTo(result);
}
values.put(mDateTimeListFieldName, result.toString());
}
catch (IOException e)
{
throw new RuntimeException("Can not serialize datetime list.");
}
}
else
{
values.put(mDateTimeListFieldName, (Long) null);
}
}