本文整理了Java中org.eigenbase.util14.ZonelessDatetime
类的一些代码示例,展示了ZonelessDatetime
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonelessDatetime
类的具体详情如下:
包路径:org.eigenbase.util14.ZonelessDatetime
类名称:ZonelessDatetime
[英]ZonelessDatetime is an abstract class for dates, times, or timestamps that contain a zoneless time value.
[中]ZonelessDatetime是包含无区域时间值的日期、时间或时间戳的抽象类。
代码示例来源:origin: org.apache.optiq/optiq-core
/**
* Gets the date portion of this zoneless datetime.
*/
public long getDateValue() {
return internalTime - getTimeValue();
}
代码示例来源:origin: org.apache.optiq/optiq-core
private static void printDatetime(
PrintWriter pw,
ZonelessDatetime datetime,
Comparable value) {
assert value instanceof Calendar;
datetime.setZonelessTime(
((Calendar) value).getTimeInMillis());
pw.print(datetime);
}
代码示例来源:origin: org.apache.optiq/optiq-core
/**
* Clears the time component of this datetime
*/
public void clearTime() {
internalTime = getDateValue();
}
代码示例来源:origin: cascading/lingual-core
@Override
public Object coerce( Object value, Type to )
{
if( value == null )
return null;
Class from = value.getClass();
if( from != Integer.class )
throw new IllegalStateException( "was not normalized" );
// no coercion, or already in canonical form
if( to == Integer.class || to == int.class || to == Object.class )
return value;
if( to == Long.class )
return ( (Integer) value ).intValue();
ZonelessDatetime date = createInstance();
date.setZonelessTime( (Integer) value % MILLIS_PER_DAY );
if( to == String.class )
return date.toString();
if( to == java.sql.Date.class )
return new java.sql.Date( date.getJdbcDate( DateTimeUtil.defaultZone ) );
if( to == java.sql.Timestamp.class )
return new java.sql.Timestamp( date.getJdbcTimestamp( DateTimeUtil.defaultZone ) );
if( to == java.sql.Time.class )
return new java.sql.Time( date.getJdbcTime( DateTimeUtil.defaultZone ) );
throw new CascadingException( "unknown type coercion requested, from: " + Util.getTypeName( from ) + " to: " + Util.getTypeName( to ) );
}
}
代码示例来源:origin: cascading/lingual-core
@Override
public Object coerce( Object value, Type to )
{
if( value == null )
return null;
Class from = value.getClass();
if( from != Integer.class )
throw new IllegalStateException( "was not normalized" );
// no coercion, or already in canonical form
if( to == Integer.class || to == int.class || to == Object.class )
return value;
if( to == Long.class )
return ( (Integer) value ).intValue();
// offset by the current timezone so we get only yyyy-mm-hh precision per the spec for DATE
// Even with a "cast" of DATE to TIMESTAMP the value should be considered "yyyy-mm-hh 00:00:00"
Calendar calendar = Calendar.getInstance();
int timezoneOffset = calendar.get( Calendar.ZONE_OFFSET ) + calendar.get( Calendar.DST_OFFSET );
long shiftedTime = ( ( (Integer) value ).longValue() * MILLIS_PER_DAY ) + timezoneOffset;
ZonelessDatetime date = createInstance();
date.setZonedTime( shiftedTime, DateTimeUtil.defaultZone );
if( to == String.class )
return date.toString();
if( to == java.sql.Date.class )
return new java.sql.Date( date.getJdbcDate( DateTimeUtil.defaultZone ) );
if( to == java.sql.Timestamp.class )
return new java.sql.Timestamp( date.getJdbcTimestamp( DateTimeUtil.defaultZone ) );
if( to == java.sql.Time.class )
return new java.sql.Time( date.getJdbcTime( DateTimeUtil.defaultZone ) );
throw new CascadingException( "unknown type coercion requested, from: " + Util.getTypeName( from ) + " to: " + Util.getTypeName( to ) );
}
代码示例来源:origin: org.apache.optiq/optiq-core
public void setZonedTime(long value, TimeZone zone) {
super.setZonedTime(value, zone);
clearTime();
}
代码示例来源:origin: org.apache.optiq/optiq-core
/**
* Gets the value of this datetime as a milliseconds value for {@link
* java.sql.Date}.
*
* @param zone time zone in which to generate a time value for
*/
public long getJdbcDate(TimeZone zone) {
Calendar cal = getCalendar(DateTimeUtil.GMT_ZONE);
cal.setTimeInMillis(getDateValue());
int year = cal.get(Calendar.YEAR);
int doy = cal.get(Calendar.DAY_OF_YEAR);
cal.clear();
cal.setTimeZone(zone);
cal.set(Calendar.YEAR, year);
cal.set(Calendar.DAY_OF_YEAR, doy);
return cal.getTimeInMillis();
}
代码示例来源:origin: org.apache.optiq/optiq-core
/**
* Gets the value of this datetime as a milliseconds value for {@link
* java.sql.Timestamp}.
*
* @param zone time zone in which to generate a time value for
*/
public long getJdbcTimestamp(TimeZone zone) {
Calendar cal = getCalendar(DateTimeUtil.GMT_ZONE);
cal.setTimeInMillis(internalTime);
int year = cal.get(Calendar.YEAR);
int doy = cal.get(Calendar.DAY_OF_YEAR);
int hour = cal.get(Calendar.HOUR_OF_DAY);
int minute = cal.get(Calendar.MINUTE);
int second = cal.get(Calendar.SECOND);
int millis = cal.get(Calendar.MILLISECOND);
cal.clear();
cal.setTimeZone(zone);
cal.set(Calendar.YEAR, year);
cal.set(Calendar.DAY_OF_YEAR, doy);
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, minute);
cal.set(Calendar.SECOND, second);
cal.set(Calendar.MILLISECOND, millis);
return cal.getTimeInMillis();
}
代码示例来源:origin: cascading/lingual-core
@Override
public Object canonical( Object value )
{
if( value == null )
return null;
Class from = value.getClass();
if( from == String.class )
return parse( (String) value ).getJdbcTimestamp( DateTimeUtil.defaultZone );
if( Date.class.isAssignableFrom( from ) )
return ( (Date) value ).getTime(); // in UTC
if( from == Long.class || from == long.class )
return value;
throw new CascadingException( "unknown type coercion requested from: " + Util.getTypeName( from ) );
}
代码示例来源:origin: cascading/lingual-core
@Override
public Object coerce( Object value, Type to )
{
if( value == null )
return null;
Class from = value.getClass();
if( from != Long.class )
throw new IllegalStateException( "was not normalized" );
// TIMESTAMP has no timezone precision so set this for the current timezone
long timezoneOffset = TimeZone.getDefault().getOffset( (Long) value );
value = ( (Long) value ) + timezoneOffset;
// no coercion, or already in canonical form
if( to == Long.class || to == long.class || to == Object.class )
return value;
if( to == Integer.class )
return ( (Long) value ).intValue();
ZonelessDatetime date = createInstance();
date.setZonelessTime( (Long) value );
if( to == String.class )
return date.toString();
if( to == java.sql.Date.class )
return new java.sql.Date( date.getJdbcDate( DateTimeUtil.defaultZone ) );
if( to == java.sql.Timestamp.class )
return new java.sql.Timestamp( date.getJdbcTimestamp( DateTimeUtil.defaultZone ) );
if( to == java.sql.Time.class )
return new java.sql.Time( date.getJdbcTime( DateTimeUtil.defaultZone ) );
throw new CascadingException( "unknown type coercion requested, from: " + Util.getTypeName( from ) + " to: " + Util.getTypeName( to ) );
}
代码示例来源:origin: net.hydromatic/optiq
public void setZonedTime(long value, TimeZone zone)
{
super.setZonedTime(value, zone);
clearDate();
}
代码示例来源:origin: net.hydromatic/optiq
/**
* Gets the value of this datetime as a milliseconds value for {@link
* java.sql.Date}.
*
* @param zone time zone in which to generate a time value for
*/
public long getJdbcDate(TimeZone zone)
{
Calendar cal = getCalendar(DateTimeUtil.gmtZone);
cal.setTimeInMillis(getDateValue());
int year = cal.get(Calendar.YEAR);
int doy = cal.get(Calendar.DAY_OF_YEAR);
cal.clear();
cal.setTimeZone(zone);
cal.set(Calendar.YEAR, year);
cal.set(Calendar.DAY_OF_YEAR, doy);
return cal.getTimeInMillis();
}
代码示例来源:origin: net.hydromatic/optiq
/**
* Gets the value of this datetime as a milliseconds value for {@link
* java.sql.Timestamp}.
*
* @param zone time zone in which to generate a time value for
*/
public long getJdbcTimestamp(TimeZone zone)
{
Calendar cal = getCalendar(DateTimeUtil.gmtZone);
cal.setTimeInMillis(internalTime);
int year = cal.get(Calendar.YEAR);
int doy = cal.get(Calendar.DAY_OF_YEAR);
int hour = cal.get(Calendar.HOUR_OF_DAY);
int minute = cal.get(Calendar.MINUTE);
int second = cal.get(Calendar.SECOND);
int millis = cal.get(Calendar.MILLISECOND);
cal.clear();
cal.setTimeZone(zone);
cal.set(Calendar.YEAR, year);
cal.set(Calendar.DAY_OF_YEAR, doy);
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, minute);
cal.set(Calendar.SECOND, second);
cal.set(Calendar.MILLISECOND, millis);
return cal.getTimeInMillis();
}
代码示例来源:origin: net.hydromatic/optiq
/**
* Clears the date component of this datetime
*/
public void clearDate()
{
internalTime = getTimeValue();
}
代码示例来源:origin: net.hydromatic/optiq
private static void printDatetime(
PrintWriter pw,
ZonelessDatetime datetime,
Comparable value)
{
assert (value instanceof Calendar);
datetime.setZonelessTime(
((Calendar) value).getTimeInMillis());
pw.print(datetime);
}
代码示例来源:origin: net.hydromatic/optiq
public void setZonedTime(long value, TimeZone zone)
{
super.setZonedTime(value, zone);
clearTime();
}
代码示例来源:origin: net.hydromatic/optiq
/**
* Clears the time component of this datetime
*/
public void clearTime()
{
internalTime = getDateValue();
}
代码示例来源:origin: org.apache.optiq/optiq-core
/**
* Clears the date component of this datetime
*/
public void clearDate() {
internalTime = getTimeValue();
}
代码示例来源:origin: net.hydromatic/optiq
public void setZonelessTime(long value)
{
super.setZonelessTime(value);
clearTime();
}
代码示例来源:origin: org.apache.optiq/optiq-core
public void setZonedTime(long value, TimeZone zone) {
super.setZonedTime(value, zone);
clearDate();
}
内容来源于网络,如有侵权,请联系作者删除!