当前位置 : 主页 > 网络编程 > 其它编程 >

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

来源:互联网 收集:自由互联 发布时间:2023-07-02
本文整理了Java中org.joda.time.DateTime.toInstant()方法的一些代码示例,展示了DateTime.toInstant() 本文整理了Java中org.joda.time.DateTime.toInstant()方法的一些代码示例,展示了DateTime.toInstant()的具体用
本文整理了Java中org.joda.time.DateTime.toInstant()方法的一些代码示例,展示了DateTime.toInstant()

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

DateTime.toInstant介绍

暂无

代码示例

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

@Override public Instant convert(DateTime source) { return source.toInstant(); }}

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

@Override public Instant convert(DateTime source) { return source.toInstant(); }}

代码示例来源:origin: joda-time/joda-time

/** * Parses an {@code Instant} from the specified string using a formatter. * * @param str the string to parse, not null * @param formatter the formatter to use, not null * @since 2.0 */public static Instant parse(String str, DateTimeFormatter formatter) { return formatter.parseDateTime(str).toInstant();}

代码示例来源:origin: JodaOrg/joda-time

/** * Parses an {@code Instant} from the specified string using a formatter. * * @param str the string to parse, not null * @param formatter the formatter to use, not null * @since 2.0 */public static Instant parse(String str, DateTimeFormatter formatter) { return formatter.parseDateTime(str).toInstant();}

代码示例来源:origin: alibaba/fastjson

out.writeLong(dateTime.toDateTime(DateTimeZone.forTimeZone(JSON.defaultTimeZone)).toInstant().getMillis());

代码示例来源:origin: com.alibaba/fastjson

out.writeLong(dateTime.toDateTime(DateTimeZone.forTimeZone(JSON.defaultTimeZone)).toInstant().getMillis());

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

/** * Parses a {@code Instant} from the specified string using a formatter. * * @param str the string to parse, not null * @param formatter the formatter to use, not null * @since 2.0 */public static Instant parse(String str, DateTimeFormatter formatter) { return formatter.parseDateTime(str).toInstant();}

代码示例来源:origin: stanfordnlp/CoreNLP

public static Partial resolveDowToDay(Partial p){ if (p.isSupported(DateTimeFieldType.dayOfWeek())) { if (!p.isSupported(DateTimeFieldType.dayOfMonth())) { if (p.isSupported(DateTimeFieldType.weekOfWeekyear()) Instant t2 = getInstant(pwy); DateTime t1 = pwy.toDateTime(t2); Partial res = getPartial(t1.toInstant(), EMPTY_ISO_PARTIAL); DateTimeFieldType mostSpecific = getMostSpecific(p); res = discardMoreSpecificFields(res, mostSpecific.getDurationType()); return res; } } } return p;}

代码示例来源:origin: stanfordnlp/CoreNLP

public static Partial resolveWeek(Partial p1, Partial p2){ if (isCompatible(p1,p2)) { if (!p1.isSupported(DateTimeFieldType.dayOfMonth())) { if (p2.isSupported(DateTimeFieldType.dayOfMonth()) DateTime t1 = p1.toDateTime(t2); return getPartial(t1.toInstant(), p1.without(DateTimeFieldType.dayOfMonth()).without(DateTimeFieldType.monthOfYear()).with(DateTimeFieldType.weekOfWeekyear(), 1)); } } } return p1;}public static Partial resolveWeek(Partial p)

代码示例来源:origin: stanfordnlp/CoreNLP

public static Partial resolveDowToDay(Partial p1, Partial p2){ // Discard anything that's more specific than dayOfMonth for p2 p2 = JodaTimeUtils.discardMoreSpecificFields(p2, DateTimeFieldType.dayOfMonth()); if (isCompatible(p1,p2)) { if (p1.isSupported(DateTimeFieldType.dayOfWeek())) { if (!p1.isSupported(DateTimeFieldType.dayOfMonth())) { if (p2.isSupported(DateTimeFieldType.dayOfMonth()) DateTime t1 = p1.toDateTime(t2); return getPartial(t1.toInstant(), p1.with(DateTimeFieldType.dayOfMonth(), 1)/*.with(DateTimeFieldType.weekOfWeekyear(), 1) */); } } } } return p1;}

代码示例来源:origin: stanfordnlp/CoreNLP

public static Instant getInstant(Partial p, ZoneId timezone){ if (p == null) return null; int year = p.isSupported(DateTimeFieldType.year())? p.get(DateTimeFieldType.year()):0; if (!p.isSupported(DateTimeFieldType.year())) { if (p.isSupported(DateTimeFieldType.centuryOfEra())) { year += 100*p.get(DateTimeFieldType.centuryOfEra()); } if (p.isSupported(DateTimeFieldType.yearOfCentury())) { year += p.get(DateTimeFieldType.yearOfCentury()); } else if (p.isSupported(DecadeOfCentury)) { year += 10*p.get(DecadeOfCentury); } } int moy = p.isSupported(DateTimeFieldType.monthOfYear())? p.get(DateTimeFieldType.monthOfYear()):1; if (!p.isSupported(DateTimeFieldType.monthOfYear())) { if (p.isSupported(QuarterOfYear)) { moy += 3*(p.get(QuarterOfYear)-1); } } int dom = p.isSupported(DateTimeFieldType.dayOfMonth())? p.get(DateTimeFieldType.dayOfMonth()):1; int hod = p.isSupported(DateTimeFieldType.hourOfDay())? p.get(DateTimeFieldType.hourOfDay()):0; int moh = p.isSupported(DateTimeFieldType.minuteOfHour())? p.get(DateTimeFieldType.minuteOfHour()):0; int som = p.isSupported(DateTimeFieldType.secondOfMinute())? p.get(DateTimeFieldType.secondOfMinute()):0; int msos = p.isSupported(DateTimeFieldType.millisOfSecond())? p.get(DateTimeFieldType.millisOfSecond()):0; return new DateTime(year, moy, dom, hod, moh, som, msos, fromTimezone(timezone)).toInstant();}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/** * Parses a {@code Instant} from the specified string using a formatter. * * @param str the string to parse, not null * @param formatter the formatter to use, not null * @since 2.0 */public static Instant parse(String str, DateTimeFormatter formatter) { return formatter.parseDateTime(str).toInstant();}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.joda-time

/** * Parses a {@code Instant} from the specified string using a formatter. * * @param str the string to parse, not null * @param formatter the formatter to use, not null * @since 2.0 */public static Instant parse(String str, DateTimeFormatter formatter) { return formatter.parseDateTime(str).toInstant();}

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

DateTime local = DateTime.now()Date localJDK = local.toDate()assert localJDK.getTime() == local.toInstant().getMillis()DateTime differentTimeZOne= DateTime.now(DateTimeZone.forID('America/Chicago'))Date localJDK2 = differentTimeZone.toDate()assert differentTimeZone.toInstant().getMillis() == localJDK2.getTime()assert localJDK.getTime() == localJDK2.getTime()

代码示例来源:origin: org.apache.beam/beam-sdks-java-core

@Overridepublic IntervalWindow assignWindow(Instant timestamp) { DateTime datetime = new DateTime(timestamp, timeZone); int dayOffset = Days.daysBetween(startDate, datetime).getDays() / number * number; DateTime begin = startDate.plusDays(dayOffset); DateTime end = begin.plusDays(number); return new IntervalWindow(begin.toInstant(), end.toInstant());}

代码示例来源:origin: org.apache.beam/beam-sdks-java-core

@Overridepublic void populateDisplayData(DisplayData.Builder builder) { super.populateDisplayData(builder); builder .add(DisplayData.item("numYears", number).withLabel("Window Years")) .addIfNotDefault( DisplayData.item("startDate", new DateTime(startDate, timeZone).toInstant()) .withLabel("Window Start Date"), new DateTime(DEFAULT_START_DATE, DateTimeZone.UTC).toInstant());}

代码示例来源:origin: org.apache.beam/beam-sdks-java-core

@Overridepublic IntervalWindow assignWindow(Instant timestamp) { DateTime datetime = new DateTime(timestamp, timeZone); DateTime offsetStart = startDate.withMonthOfYear(monthOfYear).withDayOfMonth(dayOfMonth); int yearOffset = Years.yearsBetween(offsetStart, datetime).getYears() / number * number; DateTime begin = offsetStart.plusYears(yearOffset); DateTime end = begin.plusYears(number); return new IntervalWindow(begin.toInstant(), end.toInstant());}

代码示例来源:origin: org.opencds.cqf/cql-engine

@Overridepublic Boolean equal(Object other) { if (this.getPartial().size() != ((BaseTemporal) other).getPartial().size()) { // Uncertainty return null; } return ((BaseTemporal) other).getJodaDateTime().toInstant().compareTo(this.getJodaDateTime().toInstant()) == 0;}

代码示例来源:origin: googleads/googleads-java-lib

@Testpublic void testToDateTime_fromInstantToApiDateTime() { assertEquals(apiDateTime1, dateTimesHelper.toDateTime(jodaDateTime1.toInstant(), TIME_ZONE_ID1)); assertEquals(apiDateTime2, dateTimesHelper.toDateTime(jodaDateTime2.toInstant(), TIME_ZONE_ID2)); assertEquals(apiDateTime3, dateTimesHelper.toDateTime(jodaDateTime3.toInstant(), TIME_ZONE_ID3));}

代码示例来源:origin: googleads/googleads-java-lib

@Testpublic void testTransitive_instantApiJoda() { assertEquals(jodaDateTime1, dateTimesHelper.toDateTime( dateTimesHelper.toDateTime(jodaDateTime1.toInstant(), TIME_ZONE_ID1))); assertEquals(jodaDateTime2, dateTimesHelper.toDateTime( dateTimesHelper.toDateTime(jodaDateTime2.toInstant(), TIME_ZONE_ID2))); assertEquals(jodaDateTime3, dateTimesHelper.toDateTime( dateTimesHelper.toDateTime(jodaDateTime3.toInstant(), TIME_ZONE_ID3)));}

上一篇:如何查看oracle的sid
下一篇:没有了
网友评论