本文整理了Java中org.joda.time.DateTime.toDateTime()
方法的一些代码示例,展示了DateTime.toDateTime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTime.toDateTime()
方法的具体详情如下:
包路径:org.joda.time.DateTime
类名称:DateTime
方法名:toDateTime
[英]Get this object as a DateTime by returning this
.
[中]通过返回this
获取此对象作为日期时间。
代码示例来源:origin: stackoverflow.com
DateTimeZone timeZoneNorway = DateTimeZone.forID( "Europe/Oslo" );
DateTime birthDateTime_InNorway = new DateTime( 1985, 1, 1, 3, 2, 1, timeZoneNorway );
DateTimeZone timeZoneNewYork = DateTimeZone.forID( "America/New_York" );
DateTime birthDateTime_InNewYork = birthDateTime_InNorway.toDateTime( timeZoneNewYork );
DateTime birthDateTime_UtcGmt = birthDateTime_InNorway.toDateTime( DateTimeZone.UTC );
LocalDate birthDate = new LocalDate( 1985, 1, 1 );
代码示例来源:origin: killbill/killbill
public static DateTime toUTCDateTime(final Date date) {
return new DateTime(date).toDateTime(DateTimeZone.UTC);
}
}
代码示例来源:origin: stackoverflow.com
//java.sql.Timestamp timestamp = resultSet.getTimestamp(i);
// Or, fake it
// long m = DateTime.now().getMillis();
// java.sql.Timestamp timestamp = new java.sql.Timestamp( m );
//DateTime dateTimeUtc = new DateTime( timestamp.getTime(), DateTimeZone.UTC );
DateTime dateTimeUtc = new DateTime( DateTimeZone.UTC ); // Defaults to now, this moment.
// Convert as needed for presentation to user in local time zone.
DateTimeZone timeZone = DateTimeZone.forID("Europe/Paris");
DateTime dateTimeZoned = dateTimeUtc.toDateTime( timeZone );
代码示例来源:origin: killbill/killbill
protected DateTime getDateTime(final ResultSet rs, final String fieldName) throws SQLException {
final Timestamp resultStamp = rs.getTimestamp(fieldName);
return rs.wasNull() ? null : new DateTime(resultStamp).toDateTime(DateTimeZone.UTC);
}
代码示例来源:origin: stackoverflow.com
DateTime utc = new DateTime(DateTimeZone.UTC);
DateTimeZone tz = DateTimeZone.forID("America/Los_Angeles");
DateTime losAngelesDateTime = utc.toDateTime(tz);
代码示例来源:origin: ebean-orm/ebean
@Override
protected String toJsonNanos(DateTime value) {
return String.valueOf(value.toDateTime().getMillis());
}
代码示例来源:origin: org.kill-bill.commons/killbill-clock
/**
* Create a DateTime object using the specified timezone
*
* @param dateTime DateTime to convert
* @param accountTimeZone Target timezone
* @return DateTime representing the input dateTime in the specified timezone
*/
public static DateTime toDateTime(final DateTime dateTime, final DateTimeZone accountTimeZone) {
return dateTime.toDateTime(accountTimeZone);
}
}
代码示例来源:origin: org.n52.sensorweb.sos/coding-uvf
private DateTime checkTimeZone(DateTime time) {
if (timeZone != null) {
return time.toDateTime(timeZone);
}
return time;
}
代码示例来源:origin: stackoverflow.com
// © 2013 Basil Bourque. This source code may be used freely forever by anyone taking full responsibility for doing so.
// import org.joda.time.*;
// import org.joda.time.format.*;
DateTimeZone timeZone = DateTimeZone.forID( "Europe/Athens" );
DateTime now_Athens = new DateTime( timeZone );
DateTime now_Seattle = now_Athens.toDateTime( DateTimeZone.forID( "America/Los_Angeles" ));
DateTime now_UTC = now_Athens.toDateTime( DateTimeZone.UTC );
代码示例来源:origin: stackoverflow.com
// Specify a time zone rather than rely on default.
DateTimeZone timeZone_Boston = DateTimeZone.forID( "America/New_York" );
DateTimeZone timeZone_London = DateTimeZone.forID( "Europe/London" );
DateTime dateTime_Boston = new DateTime( 2013, 10, 27, 22, 51, 12, timeZone_Boston );
DateTime dateTime_London = dateTime_Boston.toDateTime( timeZone_London );
DateTime earlier_London = dateTime_London.minusDays( 2 ); // Use '2' to get us before DST change.
DateTime earlier_UtcGmt = earlier_London.toDateTime( DateTimeZone.UTC );
代码示例来源:origin: stackoverflow.com
// Better to specify a time zone explicitly than rely on default.
// Use time zone names, not 3-letter codes.
// This list is not quite up-to-date (read page for details): http://joda-time.sourceforge.net/timezones.html
DateTimeZone timeZone = DateTimeZone.forID("Australia/Sydney");
DateTime dateTime = new DateTime(2014, 1, 14, 11, 12, 0, timeZone);
DateTime dateTimeUtc = dateTime.toDateTime(DateTimeZone.UTC); // Built-in constant for UTC (no time zone offset).
代码示例来源:origin: stackoverflow.com
// Specify a time zone rather than depend on defaults.
DateTimeZone timeZoneKolkata = DateTimeZone.forID( "Asia/Kolkata" );
long millis = 1389975349000L;
DateTime dateTimeUtc = new DateTime( millis, DateTimeZone.UTC );
DateTime dateTimeKolkata = dateTimeUtc.toDateTime( timeZoneKolkata );
代码示例来源:origin: org.sonatype.nexus.plugins/nexus-repository-npm
/**
* Returns a formatted date string suitable for a search response package entry.
*/
private String formatSearchResponsePackageDate(final DateTime dateTime) {
return SEARCH_RESPONSE_PACKAGE_DATE_FORMAT.print(dateTime.toDateTime(DateTimeZone.UTC));
}
代码示例来源:origin: stackoverflow.com
String input = "Thu Jan 1 19:30:00 UTC+0530 1970";
DateTimeFormatter formatter = DateTimeFormat.forPattern( "EEE MMM dd HH:mm:ss 'UTC'Z yyyy" );
// Adding "withOffsetParsed()" means "set new DateTime's time zone offset to match input string".
DateTime dateTime = formatter.withOffsetParsed().parseDateTime( input );
// Convert to UTC/GMT (no time zone offset).
DateTime dateTimeUtc = dateTime.toDateTime( DateTimeZone.UTC );
// Convert to India time zone. That is +05:30 (notice half-hour difference).
DateTime dateTimeIndia = dateTimeUtc.toDateTime( DateTimeZone.forID( "Asia/Kolkata" ) );
代码示例来源:origin: restx/restx
public RestxException raise() {
return new RestxException(
id,
DateTime.now().toDateTime(DateTimeZone.UTC),
errorStatus, error,
description,
ImmutableMap.copyOf(data));
}
代码示例来源:origin: io.restx/restx-core
public RestxException raise() {
return new RestxException(
id,
DateTime.now().toDateTime(DateTimeZone.UTC),
errorStatus, error,
description,
ImmutableMap.copyOf(data));
}
代码示例来源:origin: org.kill-bill.commons/killbill-clock
public static DateTime toUTCDateTime(final DateTime input) {
if (input == null) {
return null;
}
final DateTime result = input.toDateTime(DateTimeZone.UTC);
return truncateMs(result);
}
代码示例来源:origin: be.fedict.eid-dss/eid-dss-model
private DateTime getExpiration() {
Integer documentStorageExpiration = this.configuration.getValue(
ConfigProperty.DOCUMENT_STORAGE_EXPIRATION, Integer.class);
if (null == documentStorageExpiration || documentStorageExpiration <= 0) {
throw new RuntimeException("Invalid document storage validity: "
+ documentStorageExpiration);
}
return new DateTime().plus(documentStorageExpiration * 60 * 1000)
.toDateTime(ISOChronology.getInstanceUTC());
}
代码示例来源:origin: caelum/vraptor
public DateTime convert(String value, Class<? extends DateTime> type, ResourceBundle bundle) {
try {
DateTime out = new LocaleBasedJodaTimeConverter(localization).convert(value, shortDateTime());
if (out == null) {
return null;
}
return out.toDateTime();
} catch (Exception e) {
throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_datetime"), value));
}
}
}
代码示例来源:origin: org.dataconservancy.model/dcs-ui-model-builder-xstream
@Override
public void marshal(Object source,
HierarchicalStreamWriter writer,
MarshallingContext context) {
super.marshal(source, writer, context);
final DateTime date = ((DateTime) source).toDateTime(DateTimeZone.UTC);
writer.startNode(E_DATE);
writer.setValue(fmt.print(date));
writer.endNode();
}
内容来源于网络,如有侵权,请联系作者删除!