本文整理汇总了Java中org.dmfs.rfc5545.DateTime类的典型用法代码示例。如果您正苦于以下问题:Java DateTime类的具体用法?Java DateTime怎么用?Java DateTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DateTime类属于org.dmfs.rfc5545包,在下文中一共展示了DateTime类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testWithDueDateAndOriginalTime
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
@Test
public void testWithDueDateAndOriginalTime() throws Exception
{
DateTime due = DateTime.now();
DateTime original = due.addDuration(Duration.parse("P2DT2H"));
assertThat(new InstanceTestData(absent(), new Present<>(due), new Present<>(original), 5),
builds(
withValuesOnly(
withNullValue(TaskContract.Instances.INSTANCE_START),
withNullValue(TaskContract.Instances.INSTANCE_START_SORTING),
containing(TaskContract.Instances.INSTANCE_DUE, due.getTimestamp()),
containing(TaskContract.Instances.INSTANCE_DUE_SORTING, due.swapTimeZone(TimeZone.getDefault()).getInstance()),
withNullValue(TaskContract.Instances.INSTANCE_DURATION),
containing(TaskContract.Instances.INSTANCE_ORIGINAL_TIME, original.getTimestamp()),
containing(TaskContract.Instances.DISTANCE_FROM_CURRENT, 5),
withNullValue(TaskContract.Instances.DTSTART),
containing(TaskContract.Instances.DUE, due.getTimestamp()),
containing(TaskContract.Instances.ORIGINAL_INSTANCE_TIME, original.getTimestamp()),
withNullValue(TaskContract.Instances.DURATION),
withNullValue(TaskContract.Instances.RRULE),
withNullValue(TaskContract.Instances.RDATE),
withNullValue(TaskContract.Instances.EXDATE)
)
));
}
开发者ID:dmfs,项目名称:opentasks,代码行数:26,代码来源:InstanceTestDataTest.java
示例2: peekDateTime
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
/**
* Peek at the next instance to be returned by {@link #nextDateTime()} without actually iterating it. Calling this method (even multiple times) won't affect
* the instances returned by {@link #nextDateTime()}.
*
* @return the upcoming instance or <code>null</code> if there are no more instances.
*/
public DateTime peekDateTime()
{
if (mNextInstance == Long.MIN_VALUE)
{
throw new ArrayIndexOutOfBoundsException("No more instances to iterate.");
}
long nextInstance = mNextInstance;
if (mAllDay)
{
return mNextDateTime = new DateTime(mCalendarMetrics, Instance.year(nextInstance),
Instance.month(nextInstance), Instance.dayOfMonth(nextInstance));
}
else
{
return mNextDateTime = new DateTime(mCalendarMetrics, mTimeZone, Instance.year(nextInstance),
Instance.month(nextInstance),
Instance.dayOfMonth(nextInstance), Instance.hour(nextInstance), Instance.minute(nextInstance),
Instance.second(nextInstance));
}
}
开发者ID:dmfs,项目名称:lib-recur,代码行数:28,代码来源:RecurrenceRuleIterator.java
示例3: test_whenHasTimeZoneNotAllDay_setsValuesAccordingly_andNullsOtherTimeRelatedValues
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
@Test
public void test_whenHasTimeZoneNotAllDay_setsValuesAccordingly_andNullsOtherTimeRelatedValues()
{
DateTime due = DateTime.now().shiftTimeZone(TimeZone.getTimeZone("GMT+4"));
assertThat(new DueData(due),
builds(
withValuesOnly(
containing(Tasks.DUE, due.getTimestamp()),
containing(Tasks.TZ, "GMT+04:00"),
containing(Tasks.IS_ALLDAY, 0),
withNullValue(Tasks.DTSTART),
withNullValue(Tasks.DURATION),
withNullValue(Tasks.RDATE),
withNullValue(Tasks.RRULE),
withNullValue(Tasks.EXDATE)
)));
}
开发者ID:dmfs,项目名称:opentasks,代码行数:22,代码来源:DueDataTest.java
示例4: test_whenOnlyStartIsProvided_setsItAndNullsDueAndDuration
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
@Test
public void test_whenOnlyStartIsProvided_setsItAndNullsDueAndDuration()
{
DateTime start = DateTime.now();
assertThat(new TimeData(start),
builds(
withValuesOnly(
containing(Tasks.DTSTART, start.getTimestamp()),
containing(Tasks.TZ, "UTC"),
containing(Tasks.IS_ALLDAY, 0),
withNullValue(Tasks.DUE),
withNullValue(Tasks.DURATION),
withNullValue(Tasks.RDATE),
withNullValue(Tasks.RRULE),
withNullValue(Tasks.EXDATE)
)));
}
开发者ID:dmfs,项目名称:opentasks,代码行数:22,代码来源:TimeDataTest.java
示例5: getFrom
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
@Override
public DateTime getFrom(ContentValues values)
{
Long timestamp = values.getAsLong(mTimestampField);
if (timestamp == null)
{
// if the time stamp is null we return null
return null;
}
// create a new Time for the given time zone, falling back to UTC if none is given
String timezone = mTzField == null ? null : values.getAsString(mTzField);
DateTime value = new DateTime(timezone == null ? DateTime.UTC : TimeZone.getTimeZone(timezone), timestamp);
// cache mAlldayField locally
String allDayField = mAllDayField;
// set the allday flag appropriately
Integer allDayInt = allDayField == null ? null : values.getAsInteger(allDayField);
if ((allDayInt != null && allDayInt != 0) || (allDayField == null && mAllDayDefault))
{
value = value.toAllDay();
}
return value;
}
开发者ID:dmfs,项目名称:opentasks-provider,代码行数:27,代码来源:DateTimeFieldAdapter.java
示例6: test_whenNoTimeZoneNotAllDay_setsValuesAccordingly_andNullsOtherTimeRelatedValues
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
@Test
public void test_whenNoTimeZoneNotAllDay_setsValuesAccordingly_andNullsOtherTimeRelatedValues()
{
DateTime due = DateTime.now();
assertThat(new DueData(due),
builds(
withValuesOnly(
containing(Tasks.DUE, due.getTimestamp()),
containing(Tasks.TZ, "UTC"),
containing(Tasks.IS_ALLDAY, 0),
withNullValue(Tasks.DTSTART),
withNullValue(Tasks.DURATION),
withNullValue(Tasks.RDATE),
withNullValue(Tasks.RRULE),
withNullValue(Tasks.EXDATE)
)));
}
开发者ID:dmfs,项目名称:opentasks,代码行数:22,代码来源:DueDataTest.java
示例7: testInstance
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
public void testInstance(DateTime instance)
{
if (printInstances)
{
System.out.println(instance.toString());
}
assertMonth(instance);
assertWeekday(instance);
assertUntil(instance);
assertWeek(instance);
assertMonthday(instance);
assertHours(instance);
assertMinutes(instance);
assertSeconds(instance);
assertAllDay(instance);
assertTimeZone(instance);
}
开发者ID:dmfs,项目名称:lib-recur,代码行数:18,代码来源:TestRule.java
示例8: testToAllDay
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
public void testToAllDay()
{
DateTime calClone = cal.toAllDay();
assertEquals(0, calClone.getHours());
assertEquals(0, calClone.getMinutes());
assertEquals(0, calClone.getSeconds());
// date must stay the same
assertEquals(cal.getYear(), calClone.getYear());
assertEquals(cal.getMonth(), calClone.getMonth());
assertEquals(cal.getMonth(), calClone.getMonth());
assertTrue(calClone.isFloating());
assertTrue(calClone.isAllDay());
assertEquals(TimeZone.getTimeZone("UTC"), calClone.getTimeZone());
}
开发者ID:dmfs,项目名称:lib-recur,代码行数:19,代码来源:TestDate.java
示例9: expandRule
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
private List<DateTime> expandRule(TestRule rule)
{
try
{
RecurrenceRule r = new RecurrenceRule(rule.rule, rule.mode);
RecurrenceRuleIterator it = r.iterator(rule.start);
List<DateTime> instances = new ArrayList<DateTime>(1000);
int count = 0;
while (it.hasNext())
{
DateTime instance = it.nextDateTime();
instances.add(instance);
count++;
if (count == 10/* RecurrenceIteratorTest.MAX_ITERATIONS */)
{
break;
}
}
return instances;
}
catch (Exception e)
{
e.printStackTrace();
throw new IllegalArgumentException("Invalid testrule: " + rule.rule);
}
}
开发者ID:dmfs,项目名称:lib-recur,代码行数:27,代码来源:RecurrenceEquivalenceTest.java
示例10: testGetIteratorSyncedStartWithCount
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
@Test
public void testGetIteratorSyncedStartWithCount() throws Exception
{
AbstractRecurrenceAdapter.InstanceIterator iterator = new RecurrenceRuleAdapter(new RecurrenceRule("FREQ=MONTHLY;COUNT=3"))
.getIterator(TimeZone.getTimeZone("Europe/Berlin"), DateTime.parse("Europe/Berlin", "20170110T113012").getTimestamp());
assertThat(iterator.hasNext(), is(true));
assertThat(iterator.hasNext(), is(true));
assertThat(iterator.peek(), is(DateTime.parse("Europe/Berlin", "20170110T113012").getTimestamp()));
assertThat(iterator.peek(), is(DateTime.parse("Europe/Berlin", "20170110T113012").getTimestamp()));
assertThat(iterator.next(), is(DateTime.parse("Europe/Berlin", "20170110T113012").getTimestamp()));
assertThat(iterator.hasNext(), is(true));
assertThat(iterator.hasNext(), is(true));
assertThat(iterator.peek(), is(DateTime.parse("Europe/Berlin", "20170210T113012").getTimestamp()));
assertThat(iterator.peek(), is(DateTime.parse("Europe/Berlin", "20170210T113012").getTimestamp()));
assertThat(iterator.next(), is(DateTime.parse("Europe/Berlin", "20170210T113012").getTimestamp()));
assertThat(iterator.hasNext(), is(true));
assertThat(iterator.hasNext(), is(true));
assertThat(iterator.peek(), is(DateTime.parse("Europe/Berlin", "20170310T113012").getTimestamp()));
assertThat(iterator.peek(), is(DateTime.parse("Europe/Berlin", "20170310T113012").getTimestamp()));
assertThat(iterator.next(), is(DateTime.parse("Europe/Berlin", "20170310T113012").getTimestamp()));
assertThat(iterator.hasNext(), is(false));
assertThat(iterator.hasNext(), is(false));
}
开发者ID:dmfs,项目名称:lib-recur,代码行数:25,代码来源:RecurrenceRuleAdapterTest.java
示例11: testGetIteratorSyncedStartWithUntil
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
@Test
public void testGetIteratorSyncedStartWithUntil() throws Exception
{
AbstractRecurrenceAdapter.InstanceIterator iterator = new RecurrenceRuleAdapter(new RecurrenceRule("FREQ=MONTHLY;UNTIL=20170312T113012Z"))
.getIterator(TimeZone.getTimeZone("Europe/Berlin"), DateTime.parse("Europe/Berlin", "20170110T113012").getTimestamp());
assertThat(iterator.hasNext(), is(true));
assertThat(iterator.hasNext(), is(true));
assertThat(iterator.peek(), is(DateTime.parse("Europe/Berlin", "20170110T113012").getTimestamp()));
assertThat(iterator.peek(), is(DateTime.parse("Europe/Berlin", "20170110T113012").getTimestamp()));
assertThat(iterator.next(), is(DateTime.parse("Europe/Berlin", "20170110T113012").getTimestamp()));
assertThat(iterator.hasNext(), is(true));
assertThat(iterator.hasNext(), is(true));
assertThat(iterator.peek(), is(DateTime.parse("Europe/Berlin", "20170210T113012").getTimestamp()));
assertThat(iterator.peek(), is(DateTime.parse("Europe/Berlin", "20170210T113012").getTimestamp()));
assertThat(iterator.next(), is(DateTime.parse("Europe/Berlin", "20170210T113012").getTimestamp()));
assertThat(iterator.hasNext(), is(true));
assertThat(iterator.hasNext(), is(true));
assertThat(iterator.peek(), is(DateTime.parse("Europe/Berlin", "20170310T113012").getTimestamp()));
assertThat(iterator.peek(), is(DateTime.parse("Europe/Berlin", "20170310T113012").getTimestamp()));
assertThat(iterator.next(), is(DateTime.parse("Europe/Berlin", "20170310T113012").getTimestamp()));
assertThat(iterator.hasNext(), is(false));
assertThat(iterator.hasNext(), is(false));
}
开发者ID:dmfs,项目名称:lib-recur,代码行数:25,代码来源:RecurrenceRuleAdapterTest.java
示例12: testGetIteratorUnsyncedStartWithCount
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
@Test
public void testGetIteratorUnsyncedStartWithCount() throws Exception
{
AbstractRecurrenceAdapter.InstanceIterator iterator = new RecurrenceRuleAdapter(new RecurrenceRule("FREQ=MONTHLY;COUNT=3;BYMONTHDAY=11"))
.getIterator(TimeZone.getTimeZone("Europe/Berlin"), DateTime.parse("Europe/Berlin", "20170110T113012").getTimestamp());
// note the unsynced start is not a result, it's added separately by `RecurrenceSet`
assertThat(iterator.hasNext(), is(true));
assertThat(iterator.hasNext(), is(true));
assertThat(iterator.peek(), is(DateTime.parse("Europe/Berlin", "20170111T113012").getTimestamp()));
assertThat(iterator.peek(), is(DateTime.parse("Europe/Berlin", "20170111T113012").getTimestamp()));
assertThat(iterator.next(), is(DateTime.parse("Europe/Berlin", "20170111T113012").getTimestamp()));
assertThat(iterator.hasNext(), is(true));
assertThat(iterator.hasNext(), is(true));
assertThat(iterator.peek(), is(DateTime.parse("Europe/Berlin", "20170211T113012").getTimestamp()));
assertThat(iterator.peek(), is(DateTime.parse("Europe/Berlin", "20170211T113012").getTimestamp()));
assertThat(iterator.next(), is(DateTime.parse("Europe/Berlin", "20170211T113012").getTimestamp()));
assertThat(iterator.hasNext(), is(false));
assertThat(iterator.hasNext(), is(false));
}
开发者ID:dmfs,项目名称:lib-recur,代码行数:21,代码来源:RecurrenceRuleAdapterTest.java
示例13: getNextValidTime
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
public Date getNextValidTime() {
final long now = System.currentTimeMillis();
DateTime startDateTime = new DateTime(dtStart.getYear(), (dtStart.getMonthOfYear() - 1), dtStart.getDayOfMonth(),
dtStart.getHourOfDay(), dtStart.getMinuteOfHour(), dtStart.getSecondOfMinute());
RecurrenceRuleIterator timeIterator = recurrenceRule.iterator(startDateTime);
int count = 0;
while (timeIterator.hasNext() && (count < MAX_ITERATIONS || (recurrenceRule.hasPart(Part.COUNT) && count < recurrenceRule.getCount()))) {
count ++;
long nextRunAtTimestamp = timeIterator.nextMillis();
if (nextRunAtTimestamp >= now) {
return new Date(nextRunAtTimestamp);
}
}
return null;
}
开发者ID:HubSpot,项目名称:Singularity,代码行数:17,代码来源:RFC5545Schedule.java
示例14: insert
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
@Override
public TaskAdapter insert(SQLiteDatabase db, TaskAdapter task, boolean isSyncAdapter)
{
updateFields(db, task, isSyncAdapter);
if (!isSyncAdapter)
{
// set created date for tasks created on the device
task.set(TaskAdapter.CREATED, DateTime.now());
}
TaskAdapter result = mDelegate.insert(db, task, isSyncAdapter);
if (isSyncAdapter && result.isRecurring())
{
// task is recurring, update ORIGINAL_INSTANCE_ID of all exceptions that may already exists
ContentValues values = new ContentValues(1);
TaskAdapter.ORIGINAL_INSTANCE_ID.setIn(values, result.id());
db.update(TaskDatabaseHelper.Tables.TASKS, values, TaskContract.Tasks.ORIGINAL_INSTANCE_SYNC_ID + "=? and "
+ TaskContract.Tasks.ORIGINAL_INSTANCE_ID + " is null", new String[] { result.valueOf(TaskAdapter.SYNC_ID) });
}
return result;
}
开发者ID:dmfs,项目名称:opentasks,代码行数:24,代码来源:AutoCompleting.java
示例15: getFrom
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
@Override
public DateTime getFrom(ContentValues values)
{
Long timestamp = values.getAsLong(mTimestampField);
if (timestamp == null)
{
// if the time stamp is null we return null
return null;
}
// create a new Time for the given time zone, falling back to UTC if none is given
String timezone = mTzField == null ? null : values.getAsString(mTzField);
DateTime value = new DateTime(timezone == null ? DateTime.UTC : TimeZone.getTimeZone(timezone), timestamp);
// cache mAlldayField locally
String allDayField = mAllDayField;
// set the allday flag appropriately
Integer allDayInt = allDayField == null ? null : values.getAsInteger(allDayField);
if ((allDayInt != null && allDayInt != 0) || (allDayField == null && mAllDayDefault))
{
value = value.toAllDay();
}
return value;
}
开发者ID:dmfs,项目名称:opentasks,代码行数:27,代码来源:DateTimeFieldAdapter.java
示例16: setIn
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
@Override
public void setIn(ContentValues values, DateTime value)
{
if (value != null)
{
// just store all three parts separately
values.put(mTimestampField, value.getTimestamp());
if (mTzField != null)
{
TimeZone timezone = value.getTimeZone();
values.put(mTzField, timezone == null ? null : timezone.getID());
}
if (mAllDayField != null)
{
values.put(mAllDayField, value.isAllDay() ? 1 : 0);
}
}
else
{
// write timestamp only, other fields may still use allday and timezone
values.put(mTimestampField, (Long) null);
}
}
开发者ID:dmfs,项目名称:opentasks,代码行数:25,代码来源:DateTimeFieldAdapter.java
示例17: getFrom
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
@Override
public Iterable<DateTime> getFrom(ContentValues values)
{
String datetimeList = values.getAsString(mDateTimeListFieldName);
if (datetimeList == null)
{
// no list, return an empty Iterable
return EmptyIterable.instance();
}
// 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);
return new DateTimeList(timeZone, datetimeList);
}
开发者ID:dmfs,项目名称:opentasks,代码行数:17,代码来源:DateTimeIterableFieldAdapter.java
示例18: test_whenStartHasAllDayFlag_correspondingValueIsOne
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
@Test
public void test_whenStartHasAllDayFlag_correspondingValueIsOne()
{
DateTime start = DateTime.now().toAllDay();
DateTime due = start.addDuration(new Duration(1, 3, 0));
assertThat(new TimeData(start, due),
builds(
withValuesOnly(
containing(Tasks.DTSTART, start.getTimestamp()),
containing(Tasks.TZ, "UTC"),
containing(Tasks.IS_ALLDAY, 1),
containing(Tasks.DUE, due.getTimestamp()),
withNullValue(Tasks.DURATION),
withNullValue(Tasks.RDATE),
withNullValue(Tasks.RRULE),
withNullValue(Tasks.EXDATE)
)));
}
开发者ID:dmfs,项目名称:opentasks,代码行数:23,代码来源:TimeDataTest.java
示例19: test_whenNoTimeZoneAndAllDay_setsValuesAccordingly_andNullsOtherTimeRelatedValues
import org.dmfs.rfc5545.DateTime; //导入依赖的package包/类
@Test
public void test_whenNoTimeZoneAndAllDay_setsValuesAccordingly_andNullsOtherTimeRelatedValues()
{
DateTime due = DateTime.now().toAllDay();
assertThat(new DueData(due),
builds(
withValuesOnly(
containing(Tasks.DUE, due.getTimestamp()),
containing(Tasks.TZ, "UTC"),
containing(Tasks.IS_ALLDAY, 1),
withNullValue(Tasks.DTSTART),
withNullValue(Tasks.DURATION),
withNullValue(Tasks.RDATE),
withNullValue(Tasks.RRULE),
withNullValue(Tasks.EXDATE)
)));
}
开发者ID:dmfs,项目名称:opentasks,代码行数:22,代码来源:DueDataTest.java
示例20: 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;
}
开发者ID:dmfs,项目名称:opentasks,代码行数:30,代码来源:DateFormatter.java
注:本文中的org.dmfs.rfc5545.DateTime类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论