本文整理汇总了Java中org.dmfs.rfc5545.DateTime.shiftTimeZone方法的典型用法代码示例。如果您正苦于以下问题:Java DateTime.shiftTimeZone方法的具体用法?Java DateTime.shiftTimeZone怎么用?Java DateTime.shiftTimeZone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dmfs.rfc5545.DateTime
的用法示例。
在下文中一共展示了DateTime.shiftTimeZone方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_whenStartHasDifferentTimeZoneFromDue_shiftsStartsToDue
import org.dmfs.rfc5545.DateTime; //导入方法依赖的package包/类
@Test
public void test_whenStartHasDifferentTimeZoneFromDue_shiftsStartsToDue()
{
DateTime start = DateTime.now().swapTimeZone(TimeZone.getTimeZone("GMT+3"));
DateTime due = start.addDuration(new Duration(1, 3, 0)).swapTimeZone(TimeZone.getTimeZone("GMT+6"));
DateTime startExpected = start.shiftTimeZone(TimeZone.getTimeZone("GMT+6"));
assertThat(new TimeData(start, due),
builds(
withValuesOnly(
containing(Tasks.DTSTART, startExpected.getTimestamp()),
containing(Tasks.TZ, "GMT+06:00"),
containing(Tasks.IS_ALLDAY, 0),
containing(Tasks.DUE, due.getTimestamp()),
withNullValue(Tasks.DURATION),
withNullValue(Tasks.RDATE),
withNullValue(Tasks.RRULE),
withNullValue(Tasks.EXDATE)
)));
}
示例2: fastForward
import org.dmfs.rfc5545.DateTime; //导入方法依赖的package包/类
/**
* Skip all instances up to a specific date. <p> <strong>Note:</strong> After calling this method you should call {@link #hasNext()} before you continue
* because there might no more instances left if there is an UNTIL or COUNT part in the rule. </p>
*
* @param until
* The earliest date to be returned by the next call to {@link #nextMillis()} or {@link #nextDateTime()}.
*/
public void fastForward(DateTime until)
{
if (!hasNext())
{
return;
}
DateTime untilDate = until.shiftTimeZone(mTimeZone);
// convert until to an instance
long untilInstance = untilDate.getInstance();
long next = Instance.maskWeekday(mNextInstance);
if (untilInstance <= next)
{
// nothing to do
return;
}
RuleIterator iterator = mRuleIterator;
iterator.fastForward(untilInstance);
while (next != Long.MIN_VALUE && next < untilInstance)
{
next = iterator.next();
}
mNextInstance = next;
// invalidate mNextMillis
mNextMillis = Long.MIN_VALUE;
mNextDateTime = null;
}
示例3: 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();
}
示例4: testInsertWithStartAndDurationChangeTimeZone
import org.dmfs.rfc5545.DateTime; //导入方法依赖的package包/类
/**
* Create task with start and duration, check datetime values including generated due.
*/
@Test
public void testInsertWithStartAndDurationChangeTimeZone()
{
RowSnapshot<TaskLists> taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot<Tasks> task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));
DateTime start = DateTime.now();
Duration duration = Duration.parse("PT1H");
long durationMillis = duration.toMillis();
DateTime startNew = start.shiftTimeZone(TimeZone.getTimeZone("America/New_York"));
assertThat(new Seq<>(
new Put<>(taskList, new EmptyRowData<TaskLists>()),
new Put<>(task, new TimeData(start, duration)),
// update the task with a the same start in a different time zone
new Put<>(task, new TimeData(startNew, duration))
), resultsIn(mClient,
new Assert<>(task, new TimeData(startNew, duration)),
// note that, apart from the time zone, all values stay the same
new AssertRelated<>(
new InstanceTable(mAuthority), Instances.TASK_ID, task,
new Composite<Instances>(
new InstanceTestData(
start.shiftTimeZone(TimeZone.getDefault()),
start.shiftTimeZone(TimeZone.getDefault()).addDuration(duration),
absent(),
0),
new CharSequenceRowData<>(Tasks.TZ, "America/New_York"))
)));
}
示例5: 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);
}
}
示例6: apply
import org.dmfs.rfc5545.DateTime; //导入方法依赖的package包/类
@Override
public DateTime apply(DateTime argument)
{
return argument.shiftTimeZone(DateTime.UTC);
}