Java 类org.joda.time.base.BaseDateTime 实例源码
项目:jfixture
文件:BaseDateTimeRelay.java
@Override
public Object create(Object request, SpecimenContext context) {
if (!(request instanceof SpecimenType)) {
return new NoSpecimen();
}
SpecimenType type = (SpecimenType) request;
if (!BaseDateTime.class.isAssignableFrom(type.getRawType())) {
return new NoSpecimen();
}
try {
Date date = (Date) context.resolve(Date.class);
long instant = date.getTime();
DateTimeZone timeZone = (DateTimeZone)context.resolve(DateTimeZone.class);
return type.getRawType().getDeclaredConstructor(long.class, DateTimeZone.class).newInstance(instant, timeZone);
} catch (Exception e) {
e.printStackTrace();
return new NoSpecimen();
}
}
项目:sql-layer
文件:MDateAndTime.java
/** Pass components of {@code dt} to {@link #encodeDateTime(long, long, long, long, long, long)}. */
public static long encodeDateTime(BaseDateTime dt) {
return encodeDateTime(dt.getYear(),
dt.getMonthOfYear(),
dt.getDayOfMonth(),
dt.getHourOfDay(),
dt.getMinuteOfHour(),
dt.getSecondOfMinute());
}
项目:sql-layer
文件:MDateAndTime.java
/** Convert {@code dateTime} to milliseconds and {@link #encodeTimestamp(long, TExecutionContext)}. */
public static int encodeTimestamp(BaseDateTime dateTime, TExecutionContext context) {
return encodeTimestamp(dateTime.getMillis(), context);
}
项目:sql-layer
文件:MDateAndTime.java
public static boolean isValidTimestamp(BaseDateTime dt) {
long millis = dt.getMillis();
return (millis >= TIMESTAMP_MIN) && (millis <= TIMESTAMP_MAX);
}
项目:Pinot
文件:SegmentDescriptor.java
public BaseDateTime getStartWallTime(String timezone) {
String[] tokens = file.getName().split("_");
return StarTreeConstants.DATE_TIME_FORMATTER.withZone(DateTimeZone.forID(timezone)).parseDateTime(tokens[2]);
}
项目:BahaiCalendarLibrary
文件:BadiDate.java
@Override
public BaseDateTime getDateTime() {
return new DateTime(_gregorianYear, _gregorianMonth, _gregorianDay, 0,
0);
}
项目:BahaiCalendarLibrary
文件:BadiDate.java
/**
* Creates a BadiDate from Joda DateTime.
*
* @param Joda
* DateTime
* @return The Badi date
* @throws IllegalArgumentException
* Year is less than 1844 or greater than UPPER_YEAR_LIMIT
*/
public static BadiDate createFromDateTime(final BaseDateTime gregorianDate)
throws IllegalArgumentException {
final int year = gregorianDate.getYear();
checkGregorianYearForValidity(year);
final int doy = gregorianDate.getDayOfYear();
return createFromGregorianDoyAndYear(year, doy);
}
项目:BahaiCalendarLibrary
文件:BadiDate.java
/**
* Creates a BadiDate from Joda DateTime and considers if the sun has set.
*
* @param Joda
* DateTime
* @param sunset
* Has the sun set?
* @return The Badi date
* @throws IllegalArgumentException
* Year is less than 1844 or greater than UPPER_YEAR_LIMIT
*/
public static BadiDate createFromDateTimeWithSunset(final BaseDateTime gregorianDate,
final boolean sunset) throws IllegalArgumentException {
final int year = gregorianDate.getYear();
checkGregorianYearForValidity(year);
final int doy = gregorianDate.getDayOfYear() + (sunset==true ? 1 : 0);
return createFromGregorianDoyAndYear(year, doy);
}
项目:BahaiCalendarLibrary
文件:BaseBadiDate.java
/**
* Returns the Joda time for the Gregorian date.
*/
BaseDateTime getDateTime();