当前位置: 首页>>代码示例>>Java>>正文


Java ZonedDateTime.ofInstant方法代码示例

本文整理汇总了Java中java.time.ZonedDateTime.ofInstant方法的典型用法代码示例。如果您正苦于以下问题:Java ZonedDateTime.ofInstant方法的具体用法?Java ZonedDateTime.ofInstant怎么用?Java ZonedDateTime.ofInstant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.ZonedDateTime的用法示例。


在下文中一共展示了ZonedDateTime.ofInstant方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: factory_ofInstant_minWithMaxOffset

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void factory_ofInstant_minWithMaxOffset() {
    long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7);
    int year = Year.MIN_VALUE;
    long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970;
    Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L - OFFSET_MAX.getTotalSeconds());
    ZonedDateTime test = ZonedDateTime.ofInstant(instant, OFFSET_MAX);
    assertEquals(test.getYear(), Year.MIN_VALUE);
    assertEquals(test.getMonth().getValue(), 1);
    assertEquals(test.getDayOfMonth(), 1);
    assertEquals(test.getOffset(), OFFSET_MAX);
    assertEquals(test.getHour(), 0);
    assertEquals(test.getMinute(), 0);
    assertEquals(test.getSecond(), 0);
    assertEquals(test.getNano(), 0);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:TCKZonedDateTime.java

示例2: start

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public synchronized void start() {
	if (processThread != null) {
		throw new IllegalStateException("Cannot re-start ticker handler.");
	}
	processThread = new Thread() {
		public void run() {
			try {
				while (true) {
					TickMessage tick = tickQueue.getMessage();
					logger.info("Receive tick: " + tick);
					store(tick, tick.time / 1000 == 0);
					ZonedDateTime dt = ZonedDateTime.ofInstant(Instant.ofEpochMilli(tick.time), DEFAULT_TIMEZONE);
					list.add(dt.toLocalTime() + " $ " + tick.price + ", " + amount);
					amount = amount.add(tick.amount);
				}
			} catch (InterruptedException e) {
				logger.warn("TickerHandler was interrupted.");
			}
			// store unsaved ticker:
			storeNow();
		}
	};
	processThread.start();
}
 
开发者ID:michaelliao,项目名称:cryptoexchange,代码行数:26,代码来源:TickHandler.java

示例3: convertTick

import java.time.ZonedDateTime; //导入方法依赖的package包/类
private BaseTick convertTick(BittrexChartData data) {

        return new BaseTick(ZonedDateTime.ofInstant(data.getTimeStamp().toInstant(), ZoneId.systemDefault()),
                Decimal.valueOf(data.getOpen().toString()),
                Decimal.valueOf(data.getHigh().toString()),
                Decimal.valueOf(data.getLow().toString()),
                Decimal.valueOf(data.getClose().toString()),
                Decimal.valueOf(data.getVolume().toString()));
    }
 
开发者ID:jeperon,项目名称:freqtrade-java,代码行数:10,代码来源:BittrexDataConverter.java

示例4: doLayout

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public String doLayout(ILoggingEvent event) {
    Instant instant = Instant.ofEpochMilli(event.getTimeStamp());
    ZonedDateTime dateTime = ZonedDateTime.ofInstant(instant, ZoneId.systemDefault());
    StringBuilder log = new StringBuilder(dateTime.format(dateFormat));

    log.append(String.format(" %-5s", event.getLevel().levelStr));

    if (requireThread) {
        log.append(String.format(" [%s]", event.getThreadName()));
    }

    int lineNumber = event.getCallerData().length > 0 ? event.getCallerData()[0].getLineNumber() : 0;

    log.append(String.format(" %s:%d: ", event.getLoggerName(), lineNumber));

    ThrowableProxy proxy = (ThrowableProxy) event.getThrowableProxy();

    if (requireAlertLevel || requireErrorCode) {
        appendExtraExceptionFlags(log, AbstractLoggingException.getFromThrowableProxy(proxy));
    }

    log.append(event.getFormattedMessage()).append(CoreConstants.LINE_SEPARATOR);

    appendStackTrace(log, proxy);

    if (proxy != null) {
        loopCauses(log, proxy, 0);
    }

    return log.toString();
}
 
开发者ID:hmcts,项目名称:java-logging,代码行数:33,代码来源:ReformLoggingLayout.java

示例5: vanTimestampNaarZonedDateTime

import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Geeft de {@link ZonedDateTime} waarde van een {@link Timestamp}.
 * @param timestamp timestamp
 * @return timestamp als zonedDateTime
 */
public static ZonedDateTime vanTimestampNaarZonedDateTime(final Timestamp timestamp) {
    if (timestamp == null) {
        return null;
    }
    return ZonedDateTime.ofInstant(Instant.ofEpochMilli(timestamp.getTime()), DatumUtil.BRP_ZONE_ID);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:12,代码来源:DatumUtil.java

示例6: run

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public void run() {
	try {
		while (true) {
			Ticker ticker = tickerQueue.getMessage();
			System.out.println("Message: " + ticker);
			ZonedDateTime dt = ZonedDateTime.ofInstant(Instant.ofEpochMilli(ticker.time), DEFAULT_TIMEZONE);
			list.add(dt.toLocalTime() + " $ " + ticker.price + ", " + amount);
			this.amount.addAndGet(ticker.amount);
		}
	} catch (InterruptedException e) {

	}
}
 
开发者ID:michaelliao,项目名称:crypto-exchange,代码行数:15,代码来源:Quotation.java

示例7: getValue

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public final ZonedDateTime getValue(int index) {
    final long value = values[index];
    if (value == nullValue) {
        return null;
    } else {
        final ZoneId zone = zoneIdMap2.get(zoneIds[index]);
        final Instant instant = Instant.ofEpochMilli(value);
        return ZonedDateTime.ofInstant(instant, zone);
    }
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:13,代码来源:DenseArrayOfZonedDateTimes.java

示例8: deserialize

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public PoloniexChartData deserialize(JsonElement json, Type type, JsonDeserializationContext jdc) throws JsonParseException {
    JsonObject jo = (JsonObject) json;
    ZonedDateTime date = ZonedDateTime.ofInstant(Instant.ofEpochMilli(jo.get("date").getAsLong() * 1000), ZoneOffset.UTC);
    BigDecimal high = BigDecimal.valueOf(jo.get("high").getAsDouble());
    BigDecimal low = BigDecimal.valueOf(jo.get("low").getAsDouble());
    BigDecimal open = BigDecimal.valueOf(jo.get("open").getAsDouble());
    BigDecimal close = BigDecimal.valueOf(jo.get("close").getAsDouble());
    BigDecimal volume = BigDecimal.valueOf(jo.get("volume").getAsDouble());
    BigDecimal quoteVolume = BigDecimal.valueOf(jo.get("quoteVolume").getAsDouble());
    BigDecimal weightedAverage = BigDecimal.valueOf(jo.get("weightedAverage").getAsDouble());

    return new PoloniexChartData(date, high, low, open, close, volume, quoteVolume, weightedAverage);
}
 
开发者ID:TheCookieLab,项目名称:poloniex-api-java,代码行数:15,代码来源:PoloniexChartDataDeserializer.java

示例9: factory_ofInstant_tooLow

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void factory_ofInstant_tooLow() {
    long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7);
    int year = Year.MIN_VALUE - 1;
    long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970;
    Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L);
    ZonedDateTime.ofInstant(instant, ZoneOffset.UTC);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:TCKZonedDateTime.java

示例10: DateAsText

import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Formats the date with ISO format using the system zone.
 * @param date The date to format.
 */
public DateAsText(final Date date) {
    this(
        ZonedDateTime.ofInstant(date.toInstant(), ZoneId.of("UTC")),
        new Iso().get()
    );
}
 
开发者ID:yegor256,项目名称:cactoos,代码行数:11,代码来源:DateAsText.java

示例11: castForDescriptor

import java.time.ZonedDateTime; //导入方法依赖的package包/类
private static Object castForDescriptor(Object o, Class<?> type) {

            if(o != null){

                if(Long.class.isAssignableFrom(type)) {
                    return ((Number)o).longValue();
                }
                if(Integer.class.isAssignableFrom(type)) {
                    return ((Number)o).intValue();
                }
                if(Double.class.isAssignableFrom(type)) {
                    return ((Number)o).doubleValue();
                }
                if(Number.class.isAssignableFrom(type)) {
                    return ((Number)o).floatValue();
                }
                if(Boolean.class.isAssignableFrom(type)) {
                    return (Boolean) o;
                }
                if(ZonedDateTime.class.isAssignableFrom(type)) {
                    if(o instanceof Date){
                        return ZonedDateTime.ofInstant(((Date) o).toInstant(), ZoneId.of("UTC"));
                    }
                    return (ZonedDateTime) o;
                }
                if(Date.class.isAssignableFrom(type)) {
                    return (Date) o;
                }
                if(ByteBuffer.class.isAssignableFrom(type)) {
                    return ByteBuffer.wrap(new String((byte[]) o).getBytes()) ;
                }
            }
            return o;
        }
 
开发者ID:RBMHTechnology,项目名称:vind,代码行数:35,代码来源:SolrUtils.java

示例12: toZonedDateTime

import java.time.ZonedDateTime; //导入方法依赖的package包/类
protected ZonedDateTime toZonedDateTime(Date date) {
    return date == null ? null : ZonedDateTime.ofInstant(date.toInstant(), ZoneId.of("UTC"));
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:4,代码来源:OperationFactory.java

示例13: getStartOfToday

import java.time.ZonedDateTime; //导入方法依赖的package包/类
private static ZonedDateTime getStartOfToday() {
    return ZonedDateTime.ofInstant(Instant.now().truncatedTo(ChronoUnit.DAYS), ZoneOffset.UTC);
}
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:4,代码来源:GenerateSampleStatisticsData.java

示例14: factory_ofInstant_Instant_ZR

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void factory_ofInstant_Instant_ZR() {
    Instant instant = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 35).toInstant(OFFSET_0200);
    ZonedDateTime test = ZonedDateTime.ofInstant(instant, ZONE_PARIS);
    check(test, 2008, 6, 30, 11, 30, 10, 35, OFFSET_0200, ZONE_PARIS);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:TCKZonedDateTime.java

示例15: fromLong

import java.time.ZonedDateTime; //导入方法依赖的package包/类
public static ZonedDateTime fromLong(long value) {
  Date date = new Date(value);
  return ZonedDateTime.ofInstant(date.toInstant(), ZoneOffset.UTC);
}
 
开发者ID:EHRI,项目名称:rs-aggregator,代码行数:5,代码来源:ZonedDateTimeUtil.java


注:本文中的java.time.ZonedDateTime.ofInstant方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。