org.joda.time.DateTime.toLocalDateTime()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中org.joda.time.DateTime.toLocalDateTime()方法的一些代码示例,展示了DateTime.toLocalDateTime()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTime.toLocalDateTime()方法的具体详情如下:
包路径:org.joda.time.DateTime
类名称:DateTime
方法名:toLocalDateTime

DateTime.toLocalDateTime介绍

[英]Converts this object to a LocalDateTime with the same datetime and chronology.
[中]将此对象转换为具有相同日期时间和时间顺序的LocalDateTime

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
  public LocalDateTime convert(DateTime source) {
    return source.toLocalDateTime();
  }
}

代码示例来源:origin: org.springframework/spring-context

@Override
  public LocalDateTime convert(DateTime source) {
    return source.toLocalDateTime();
  }
}

代码示例来源:origin: apache/incubator-pinot

private Object getRandomValueForTimeColumn(boolean isSimpleDate) {
 long randomMs = ThreadLocalRandom.current().nextLong(startTime);
 long dateColVal = randomMs;
 Object result;
 if (isSimpleDate) {
  DateTime dateTime = new DateTime(randomMs);
  LocalDateTime localDateTime = dateTime.toLocalDateTime();
  int year = localDateTime.getYear();
  int month = localDateTime.getMonthOfYear();
  int day = localDateTime.getDayOfMonth();
  String dateColStr = String.format("%04d%02d%02d", year, month, day);
  dateColVal = Integer.valueOf(dateColStr);
  result = new Integer(Integer.valueOf(dateColStr));
 } else {
  result = new Long(dateColVal);
 }
 if (dateColVal < minTime) {
  minTime = dateColVal;
 }
 if (dateColVal > maxTime) {
  maxTime = dateColVal;
 }
 return result;
}

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl

return null;
return local.toLocalDateTime();

代码示例来源:origin: no.arktekk.unix/unix-common

public LocalDateTime f( DateTime dateTime )
  {
    return dateTime.toLocalDateTime();
  }
};

代码示例来源:origin: org.jadira.usertype/usertype.core

@Override
public LocalDateTime fromNonNullValue(Timestamp value) {
  DateTime dateTime = new DateTime(value.getTime());
  LocalDateTime localDateTime = dateTime.toLocalDateTime();
  return localDateTime;
}

代码示例来源:origin: stackoverflow.com

String utcTime = "2016-06-17 14:22:02Z";
DateTimeFormatter parser = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ssZ");
DateTime dateTime = parser.parseDateTime(utcTime).withZone(DateTimeZone.forID("Asia/Kolkata"));
DateTimeFormatter formatter = DateTimeFormat.forPattern("dd-MM-YYYY HH:mm:ss");
System.out.println(dateTime);
LocalDateTime localDateTime = dateTime.toLocalDateTime();
String formattedlocalDateTime = formatter.print(localDateTime);
System.out.println(formattedlocalDateTime);

代码示例来源:origin: stackoverflow.com

@Test
public void change_timezone_of_reminder() {
  DateTime originalReminderDateTime = LocalDateTime.parse("2015-05-15T15:00").toDateTime(
      DateTimeZone.forID("Europe/Berlin"));
  assertThat(originalReminderDateTime.toString(), equalTo("2015-05-15T15:00:00.000+02:00"));
  long reminderMillis = originalReminderDateTime.getMillis();
  DateTime updatedTime = new DateTime(reminderMillis, DateTimeZone.forID("Europe/Berlin"))
      .withZoneRetainFields(DateTimeZone.forID("America/New_York"));
  assertThat(updatedTime.toLocalDateTime(), equalTo(LocalDateTime.parse("2015-05-15T15:00")));
  assertThat(updatedTime.toString(), equalTo("2015-05-15T15:00:00.000-04:00"));
}

代码示例来源:origin: stackoverflow.com

//Assign utc calendar
Calendar utc= Calendar.getInstance();
utc.setTimeZone(TimeZone.getTimeZone("UTC"));
Timestamp timestamp = rs.getTimestamp("timestampcolumn", utc);
//Convert to client date time
DateTime dateTime = new DateTime(timestamp.getTime(), DateTimeZone.forID("Asia/Kolkata"));
//Format
DateTimeFormatter formatter = DateTimeFormat.forPattern("dd-MM-YYYY HH:mm:ss");
//Change to client wall clock time
LocalDateTime localDateTime = dateTime.toLocalDateTime();
String formattedlocalDateTime = formatter.print(localDateTime)

代码示例来源:origin: stackoverflow.com

DateTime dateTimePlus2 = DateTime.parse("2015-07-09T05:10:00+02:00");
System.out.println(dateTimePlus2);

DateTime dateTimeUTC = dateTimePlus2.withZone(DateTimeZone.UTC);
System.out.println(dateTimeUTC);

LocalDateTime localDateTimeUTC = dateTimeUTC.toLocalDateTime();
System.out.println(localDateTimeUTC);

代码示例来源:origin: stackoverflow.com

@Test
public void testDateTimeConversion() {
  final Date sourceDateTime = new DateTime(2015, 3, 15, 12, 55, TIMEZONE_MOSCOW).toDate();
  final Date expectedResult =
    new DateTime(2015, 3, 15, 12 - 2, 55, TIMEZONE_BERLIN).toLocalDateTime().toDate();

  final DateTime timeInMoscow =
    new DateTime(sourceDateTime, TIMEZONE_MOSCOW);
  final DateTime timeInBerlin = timeInMoscow.toDateTime(TIMEZONE_BERLIN);
  final Date actualResult = timeInBerlin.toLocalDateTime().toDate();

  Assert.assertEquals(expectedResult, actualResult);
}

代码示例来源:origin: stackoverflow.com

public static Date convertJodaTimezone(LocalDateTime date, String srcTz, String destTz) {
  DateTime srcDateTime = date.toDateTime(DateTimeZone.forID(srcTz));
  DateTime dstDateTime = srcDateTime.withZone(DateTimeZone.forID(destTz));
  return dstDateTime.toLocalDateTime().toDateTime().toDate();
}

代码示例来源:origin: org.sonatype.sisu/sisu-odata4j

public static LocalDateTime parseDateTimeFromJson(String value) {
 DateTime dateTime = parseDateString(value);
 if (dateTime != null)
  return dateTime.toLocalDateTime();
 else
  // required to support datajs clients (although not spec compliant)
  return InternalUtil.parseDateTimeFromXml(value);
}

代码示例来源:origin: stackoverflow.com

public static Date convertJodaTimezone(LocalDateTime date, String localTimeZone, String destTimeZone) {
 DateTime srcDateTime = date.toDateTime(DateTimeZone.forID(localTimeZone));
 DateTime dstDateTime = srcDateTime.withZone(DateTimeZone.forID(destTimeZone));
 return dstDateTime.toLocalDateTime().toDateTime().toDate();
}

代码示例来源:origin: com.vlkan.rfos/rotating-fos

@Override
public LocalDateTime sundayMidnight() {
  DateTime today = currentDateTime();
  int dayIndex = today.getDayOfWeek() - 1;
  int dayOffset = 7 - dayIndex;
  DateTime monday = today.plusDays(dayOffset);
  DateTime mondayStart = monday.withTimeAtStartOfDay();
  return mondayStart.toLocalDateTime();
}

代码示例来源:origin: caelum/vraptor

public LocalDateTime convert(String value, Class<? extends LocalDateTime> type, ResourceBundle bundle) {
    try {
      DateTime out = new LocaleBasedJodaTimeConverter(localization).convert(value, shortDateTime());
      if (out == null) {
        return null;
      }
    
      return out.toLocalDateTime();
    } catch (Exception e) {
      throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_datetime"), value));
    }
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

return null;
return local.toLocalDateTime();

代码示例来源:origin: io.konig/konig-dao-core

private DateTime toDateTime(DataRange range, BoundaryPoint point) throws DaoException {
  String value = point.getValue();
  URI fieldType = range.getPath().lastField().getFieldType();
  if (fieldType.equals(XMLSchema.DATE) || fieldType.equals(XMLSchema.DATETIME)) {
    return new DateTime(value).toLocalDateTime().toDateTime(DateTimeZone.UTC);
  }
  
  throw new DaoException("Unsupported data type: " + fieldType.stringValue());
}

代码示例来源:origin: org.jadira.usertype/usertype.core

@Override
  protected Object[] toConvertedColumns(DateTime value) {
    return new Object[] { value.toLocalDateTime(), new DateTimeZoneWithOffset(value.getZone(), value.getZone().isFixed() ? null : DateTimeZone.forOffsetMillis(value.getZone().getOffset(value))) };
  }
}

代码示例来源:origin: org.jadira.usertype/usertype.core

@Override
  protected Object[] toConvertedColumns(DateTime value) {

    return new Object[] { value.toLocalDateTime(), new DateTimeZoneWithOffset(value.getZone(), value.getZone().isFixed() ? null : DateTimeZone.forOffsetMillis(value.getZone().getOffset(value))) };
  }
}

相关文章

DateTime类方法