本文整理汇总了Java中org.joda.time.ReadablePartial.isSupported方法的典型用法代码示例。如果您正苦于以下问题:Java ReadablePartial.isSupported方法的具体用法?Java ReadablePartial.isSupported怎么用?Java ReadablePartial.isSupported使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.ReadablePartial
的用法示例。
在下文中一共展示了ReadablePartial.isSupported方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMaximumValue
import org.joda.time.ReadablePartial; //导入方法依赖的package包/类
@Override
public int getMaximumValue(ReadablePartial partial) {
if (partial.isSupported(DateTimeFieldType.monthOfYear())) {
int month = partial.get(DateTimeFieldType.monthOfYear());
return this.daysInMonth[month - 1]; // Months are 1-based
}
return this.getMaximumValue();
}
示例2: isToday
import org.joda.time.ReadablePartial; //导入方法依赖的package包/类
/**
* See {@link android.text.format.DateUtils#isToday} for full docs.
*
* @return true if the supplied when is today else false
*/
public static boolean isToday(ReadablePartial time) {
if (!time.isSupported(DateTimeFieldType.dayOfMonth())
|| !time.isSupported(DateTimeFieldType.monthOfYear())
|| !time.isSupported(DateTimeFieldType.year())) {
throw new IllegalArgumentException("isToday() must be passed a ReadablePartial that supports day of " +
"month, month of year and year.");
}
LocalDate localDate = time instanceof LocalDate ? (LocalDate) time : new LocalDate(time);
return LocalDate.now().compareTo(localDate) == 0;
}
示例3: getRelativeDateTimeString
import org.joda.time.ReadablePartial; //导入方法依赖的package包/类
/**
* Return string describing the time until/elapsed time since 'time' formatted like
* "[relative time/date], [time]".
*
* See {@link android.text.format.DateUtils#getRelativeDateTimeString} for full docs.
*
* @throws IllegalArgumentException if using a ReadablePartial without a time component
* @see #getRelativeDateTimeString(Context, ReadableInstant, ReadablePeriod, int)
*/
public static CharSequence getRelativeDateTimeString(Context context, ReadablePartial time,
ReadablePeriod transitionResolution, int flags) {
if (!time.isSupported(DateTimeFieldType.hourOfDay())
|| !time.isSupported(DateTimeFieldType.minuteOfHour())) {
throw new IllegalArgumentException("getRelativeDateTimeString() must be passed a ReadablePartial that " +
"supports time, otherwise it makes no sense");
}
return getRelativeDateTimeString(context, time.toDateTime(DateTime.now()), transitionResolution, flags);
}
示例4: printTo
import org.joda.time.ReadablePartial; //导入方法依赖的package包/类
public void printTo(StringBuffer buf, ReadablePartial partial, Locale locale) {
if (partial.isSupported(iFieldType)) {
try {
FormatUtils.appendUnpaddedInteger(buf, partial.get(iFieldType));
} catch (RuntimeException e) {
buf.append('\ufffd');
}
} else {
buf.append('\ufffd');
}
}
示例5: getTwoDigitYear
import org.joda.time.ReadablePartial; //导入方法依赖的package包/类
private int getTwoDigitYear(ReadablePartial partial) {
if (partial.isSupported(iType)) {
try {
int year = partial.get(iType);
if (year < 0) {
year = -year;
}
return year % 100;
} catch (RuntimeException e) {}
}
return -1;
}
示例6: print
import org.joda.time.ReadablePartial; //导入方法依赖的package包/类
private String print(ReadablePartial partial, Locale locale) {
if (partial.isSupported(iFieldType)) {
DateTimeField field = iFieldType.getField(partial.getChronology());
if (iShort) {
return field.getAsShortText(partial, locale);
} else {
return field.getAsText(partial, locale);
}
} else {
return "\ufffd";
}
}
示例7: printTo
import org.joda.time.ReadablePartial; //导入方法依赖的package包/类
public void printTo(StringBuffer buf, ReadablePartial partial, Locale locale) {
for (DateTimeFieldType type : contingentOnFields) {
if (partial.isSupported(type)) {
buf.append(literal);
return;
}
}
}