本文整理汇总了Java中org.threeten.bp.OffsetTime.of方法的典型用法代码示例。如果您正苦于以下问题:Java OffsetTime.of方法的具体用法?Java OffsetTime.of怎么用?Java OffsetTime.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.threeten.bp.OffsetTime
的用法示例。
在下文中一共展示了OffsetTime.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTrades
import org.threeten.bp.OffsetTime; //导入方法依赖的package包/类
protected List<ManageableTrade> getTrades() {
final List<ManageableTrade> trades = Lists.newArrayList();
final ManageableTrade trade1 = new ManageableTrade(BigDecimal.valueOf(50), SEC_ID, LocalDate.parse("2011-12-07"), OffsetTime.of(LocalTime.of(15, 4), ZONE_OFFSET), COUNTER_PARTY);
trade1.setPremium(10.0);
trade1.setPremiumCurrency(Currency.USD);
trade1.setPremiumDate(LocalDate.parse("2011-12-08"));
trade1.setPremiumTime(OffsetTime.of(LocalTime.of(15, 4), ZONE_OFFSET));
trades.add(trade1);
final ManageableTrade trade2 = new ManageableTrade(BigDecimal.valueOf(60), SEC_ID, LocalDate.parse("2011-12-08"), OffsetTime.of(LocalTime.of(16, 4), ZONE_OFFSET), COUNTER_PARTY);
trade2.setPremium(20.0);
trade2.setPremiumCurrency(Currency.USD);
trade2.setPremiumDate(LocalDate.parse("2011-12-09"));
trade2.setPremiumTime(OffsetTime.of(LocalTime.of(16, 4), ZONE_OFFSET));
trades.add(trade2);
final ManageableTrade trade3 = new ManageableTrade(BigDecimal.valueOf(70), SEC_ID, LocalDate.parse("2011-12-09"), OffsetTime.of(LocalTime.of(17, 4), ZONE_OFFSET), COUNTER_PARTY);
trade3.setPremium(30.0);
trade3.setPremiumCurrency(Currency.USD);
trade3.setPremiumDate(LocalDate.parse("2011-12-10"));
trade3.setPremiumTime(OffsetTime.of(LocalTime.of(17, 4), ZONE_OFFSET));
trades.add(trade3);
return trades;
}
示例2: testSerialisation
import org.threeten.bp.OffsetTime; //导入方法依赖的package包/类
/**
* Tests that serialising to JSON works.
*/
@Test
public void testSerialisation() throws Exception
{
final Gson gson = Converters.registerAll(new GsonBuilder()).create();
final Container container = new Container();
container.ld = LocalDate.of(1969, 7, 21);
container.lt = LocalTime.of(12, 56, 0);
container.ldt = LocalDateTime.of(container.ld, container.lt);
container.odt = OffsetDateTime.of(container.ld, container.lt, ZoneOffset.ofHours(10));
container.ot = OffsetTime.of(container.lt, ZoneOffset.ofHours(10));
container.zdt = ZonedDateTime.of(container.ld, container.lt, ZoneId.of("Australia/Brisbane"));
container.i = container.odt.toInstant();
final String jsonString = gson.toJson(container);
final JsonObject json = gson.fromJson(jsonString, JsonObject.class).getAsJsonObject();
assertThat(json.get("ld").getAsString(), is("1969-07-21"));
assertThat(json.get("lt").getAsString(), is("12:56:00"));
assertThat(json.get("ldt").getAsString(), is("1969-07-21T12:56:00"));
assertThat(json.get("odt").getAsString(), is("1969-07-21T12:56:00+10:00"));
assertThat(json.get("ot").getAsString(), is("12:56:00+10:00"));
assertThat(json.get("zdt").getAsString(), is("1969-07-21T12:56:00+10:00[Australia/Brisbane]"));
assertThat(json.get("i").getAsString(), is("1969-07-21T02:56:00Z"));
}
示例3: createFxForwardTrade
import org.threeten.bp.OffsetTime; //导入方法依赖的package包/类
/**
* Create an instance of a Fx Forward Trade
* @return FXForwardTrade
*/
private static FXForwardTrade createFxForwardTrade() {
Counterparty counterparty = new SimpleCounterparty(ExternalId.of(Counterparty.DEFAULT_SCHEME, "COUNTERPARTY"));
BigDecimal tradeQuantity = BigDecimal.valueOf(1);
LocalDate tradeDate = LocalDate.of(2014, 7, 11);
OffsetTime tradeTime = OffsetTime.of(LocalTime.of(0, 0), ZoneOffset.UTC);
SimpleTrade trade = new SimpleTrade(createFxForwardSecurity(), tradeQuantity, counterparty, tradeDate, tradeTime);
trade.setPremium(0.00);
trade.setPremiumDate(LocalDate.of(2014, 7, 25));
trade.setPremiumCurrency(Currency.GBP);
FXForwardTrade fxForwardTrade = new FXForwardTrade(trade);
return fxForwardTrade;
}
示例4: createVanillaFixedVsLibor3mTrade
import org.threeten.bp.OffsetTime; //导入方法依赖的package包/类
private static InterestRateSwapTrade createVanillaFixedVsLibor3mTrade() {
Counterparty counterparty = new SimpleCounterparty(ExternalId.of(Counterparty.DEFAULT_SCHEME, "COUNTERPARTY"));
BigDecimal tradeQuantity = BigDecimal.valueOf(1);
LocalDate tradeDate = LocalDate.of(2014, 1, 22);
OffsetTime tradeTime = OffsetTime.of(LocalTime.of(0, 0), ZoneOffset.UTC);
SimpleTrade trade = new SimpleTrade(createVanillaFixedVsLibor3mSwap(), tradeQuantity, counterparty, tradeDate, tradeTime);
trade.setPremium(0.0);
trade.setPremiumDate(tradeDate);
trade.setPremiumCurrency(Currency.USD);
/* A specific InterestRateSwapTrade object here is used to 'wrap' the underlying generic SimpleTrade */
return new InterestRateSwapTrade(trade);
}
示例5: createIRFutureTrade
import org.threeten.bp.OffsetTime; //导入方法依赖的package包/类
private static InterestRateFutureTrade createIRFutureTrade() {
Expiry expiry = new Expiry(ZonedDateTime.of(LocalDate.of(2014, 6, 18), LocalTime.of(0, 0), ZoneOffset.UTC));
String tradingExchange = "";
String settlementExchange = "";
Currency currency = Currency.USD;
double unitAmount = 1000;
ExternalId underlyingId = InterestRateMockSources.getLiborIndexId();
String category = "";
InterestRateFutureSecurity irFuture = new InterestRateFutureSecurity(expiry, tradingExchange, settlementExchange,
currency, unitAmount, underlyingId, category);
// Need this for time series lookup
irFuture.setExternalIdBundle(ExternalSchemes.syntheticSecurityId("Test future").toBundle());
Counterparty counterparty = new SimpleCounterparty(ExternalId.of(Counterparty.DEFAULT_SCHEME, "COUNTERPARTY"));
BigDecimal tradeQuantity = BigDecimal.valueOf(10);
LocalDate tradeDate = LocalDate.of(2000, 1, 1);
OffsetTime tradeTime = OffsetTime.of(LocalTime.of(0, 0), ZoneOffset.UTC);
SimpleTrade trade = new SimpleTrade(irFuture, tradeQuantity, counterparty, tradeDate, tradeTime);
trade.setPremium(0.0);
trade.setPremiumCurrency(Currency.USD);
return new InterestRateFutureTrade(trade);
}
示例6: createFedFundsFutureTrade
import org.threeten.bp.OffsetTime; //导入方法依赖的package包/类
private FedFundsFutureTrade createFedFundsFutureTrade() {
Expiry expiry = new Expiry(ZonedDateTime.of(LocalDate.of(2014, 6, 18), LocalTime.of(0, 0), ZoneOffset.UTC));
String tradingExchange = "";
String settlementExchange = "";
Currency currency = Currency.USD;
double unitAmount = 1000;
ExternalId underlyingId = InterestRateMockSources.getOvernightIndexId();
String category = "";
FederalFundsFutureSecurity fedFundsFuture = new FederalFundsFutureSecurity(expiry, tradingExchange, settlementExchange, currency, unitAmount, underlyingId, category);
// Need this for time series lookup
fedFundsFuture.setExternalIdBundle(ExternalSchemes.syntheticSecurityId("Test future").toBundle());
Counterparty counterparty = new SimpleCounterparty(ExternalId.of(Counterparty.DEFAULT_SCHEME, "COUNTERPARTY"));
BigDecimal tradeQuantity = BigDecimal.valueOf(10);
LocalDate tradeDate = LocalDate.of(2000, 1, 1);
OffsetTime tradeTime = OffsetTime.of(LocalTime.of(0, 0), ZoneOffset.UTC);
SimpleTrade trade = new SimpleTrade(fedFundsFuture, tradeQuantity, counterparty, tradeDate, tradeTime);
trade.setPremiumCurrency(Currency.USD);
trade.setPremium(0.995);
return new FedFundsFutureTrade(trade);
}
示例7: createInterestRateFutureTrade
import org.threeten.bp.OffsetTime; //导入方法依赖的package包/类
private InterestRateFutureTrade createInterestRateFutureTrade(InterestRateFutureSecurity security,
SimpleCounterparty counterparty,
boolean pass) {
BigDecimal tradeQuantity = BigDecimal.valueOf(10);
LocalDate tradeDate = LocalDate.of(2000, 1, 1);
OffsetTime tradeTime = OffsetTime.of(LocalTime.of(0, 0), ZoneOffset.UTC);
SimpleTrade trade = new SimpleTrade(security, tradeQuantity, counterparty, tradeDate, tradeTime);
trade.setPremium(0.0);
trade.setPremiumCurrency(security.getCurrency());
if (pass) {
trade.addAttribute("TEST", "PASS");
} else {
trade.addAttribute("TEST", "FAIL");
}
return new InterestRateFutureTrade(trade);
}
示例8: convertFromString
import org.threeten.bp.OffsetTime; //导入方法依赖的package包/类
@Override
public OffsetTime convertFromString(Class<? extends OffsetTime> cls, String timeString) {
if (!StringUtils.isEmpty(timeString)) {
return OffsetTime.of(LocalTime.parse(timeString.trim()), ZoneOffset.UTC);
} else {
return null;
}
}
示例9: addPosition
import org.threeten.bp.OffsetTime; //导入方法依赖的package包/类
protected UniqueId addPosition() {
final ManageableTrade origTrade = new ManageableTrade(BigDecimal.valueOf(50), SEC_ID, LocalDate.parse("2011-12-07"), OffsetTime.of(LocalTime.of(15, 4), ZONE_OFFSET), COUNTER_PARTY);
origTrade.setPremium(10.0);
origTrade.setPremiumCurrency(Currency.USD);
origTrade.setPremiumDate(LocalDate.parse("2011-12-08"));
origTrade.setPremiumTime(OffsetTime.of(LocalTime.of(15, 4), ZONE_OFFSET));
final ManageablePosition manageablePosition = new ManageablePosition(origTrade.getQuantity(), EQUITY_SECURITY.getExternalIdBundle());
manageablePosition.addTrade(origTrade);
final PositionDocument addedPos = _positionMaster.add(new PositionDocument(manageablePosition));
final UniqueId uid = addedPos.getUniqueId();
return uid;
}
示例10: createBondFutureOptionTrade
import org.threeten.bp.OffsetTime; //导入方法依赖的package包/类
public static BondFutureOptionTrade createBondFutureOptionTrade() {
Counterparty counterparty = new SimpleCounterparty(ExternalId.of(Counterparty.DEFAULT_SCHEME, "COUNTERPARTY"));
BigDecimal tradeQuantity = BigDecimal.valueOf(-100);
LocalDate tradeDate = LocalDate.of(2000, 1, 1);
OffsetTime tradeTime = OffsetTime.of(LocalTime.of(0, 0), ZoneOffset.UTC);
SimpleTrade trade = new SimpleTrade(createBondFutureOptionSecurity(), tradeQuantity, counterparty, tradeDate, tradeTime);
trade.setPremium(0.0);
trade.setPremiumCurrency(Currency.JPY);
return new BondFutureOptionTrade(trade);
}
示例11: createFeeFixedVsLibor3mSwap
import org.threeten.bp.OffsetTime; //导入方法依赖的package包/类
private static InterestRateSwapTrade createFeeFixedVsLibor3mSwap() {
Counterparty counterparty = new SimpleCounterparty(ExternalId.of(Counterparty.DEFAULT_SCHEME, "COUNTERPARTY"));
BigDecimal tradeQuantity = BigDecimal.valueOf(1);
LocalDate tradeDate = LocalDate.of(2014, 1, 22);
OffsetTime tradeTime = OffsetTime.of(LocalTime.of(0, 0), ZoneOffset.UTC);
SimpleTrade trade = new SimpleTrade(createVanillaFixedVsLibor3mSwap(), tradeQuantity, counterparty, tradeDate, tradeTime);
trade.setPremium(0.0);
trade.setPremiumDate(tradeDate);
trade.setPremiumCurrency(Currency.GBP);
/* Fees are added as attributes on the Trade object.
* Multiple fees are added by grouping them in the following pattern: "FEE_{number}_{PART}.
* Fees are made up of four parts
* 1. 'DATE' in the format YYYY-MM-DD
* 2. 'CURRENCY' ISO currency code
* 3. 'AMOUNT' fee payable
* 4. 'DIRECTION' either 'PAY' or 'RECEIVE' */
trade.addAttribute("FEE_1_DATE", "2014-05-22");
trade.addAttribute("FEE_1_CURRENCY", "USD");
trade.addAttribute("FEE_1_AMOUNT", "2000");
trade.addAttribute("FEE_1_DIRECTION", "PAY");
trade.addAttribute("FEE_2_DATE", "2014-03-22");
trade.addAttribute("FEE_2_CURRENCY", "USD");
trade.addAttribute("FEE_2_AMOUNT", "1000");
trade.addAttribute("FEE_2_DIRECTION", "RECEIVE");
/* A specific InterestRateSwapTrade object here is used to 'wrap' the underlying generic SimpleTrade */
return new InterestRateSwapTrade(trade);
}
示例12: testDeserialisation
import org.threeten.bp.OffsetTime; //导入方法依赖的package包/类
/**
* Tests that deserialising from JSON works.
*/
@Test
public void testDeserialisation() throws Exception
{
final Gson gson = Converters.registerAll(new GsonBuilder()).create();
final Container container = new Container();
container.ld = LocalDate.of(1969, 7, 21);
container.lt = LocalTime.of(12, 56, 0);
container.ldt = LocalDateTime.of(container.ld, container.lt);
container.odt = OffsetDateTime.of(container.ld, container.lt, ZoneOffset.ofHours(10));
container.ot = OffsetTime.of(container.lt, ZoneOffset.ofHours(10));
container.zdt = ZonedDateTime.of(container.ld, container.lt, ZoneId.of("Australia/Brisbane"));
container.i = container.odt.toInstant();
final JsonObject serialized = new JsonObject();
serialized.add("ld", new JsonPrimitive("1969-07-21"));
serialized.add("lt", new JsonPrimitive("12:56:00"));
serialized.add("ldt", new JsonPrimitive("1969-07-21T12:56:00"));
serialized.add("odt", new JsonPrimitive("1969-07-21T12:56:00+10:00"));
serialized.add("ot", new JsonPrimitive("12:56:00+10:00"));
serialized.add("zdt", new JsonPrimitive("1969-07-21T12:56:00+10:00[Australia/Brisbane]"));
serialized.add("i", new JsonPrimitive("1969-07-21T02:56:00Z"));
final String jsonString = gson.toJson(serialized);
final Container deserialised = gson.fromJson(jsonString, Container.class);
assertThat(deserialised.ld, is(container.ld));
assertThat(deserialised.ldt, is(container.ldt));
assertThat(deserialised.lt, is(container.lt));
assertThat(deserialised.odt, is(container.odt));
assertThat(deserialised.ot, is(container.ot));
assertThat(deserialised.zdt, is(container.zdt));
assertThat(deserialised.i, is(container.i));
}
示例13: testUpdate
import org.threeten.bp.OffsetTime; //导入方法依赖的package包/类
public void testUpdate() {
Expiry expiry = new Expiry(ZonedDateTime.of(LocalDate.of(2014, 6, 18), LocalTime.of(0, 0), ZoneOffset.UTC));
String tradingExchange = "";
String settlementExchange = "";
Currency currency = Currency.USD;
double unitAmount = 1000;
ExternalId underlyingId = ExternalId.of("first", "second");
String category = "";
InterestRateFutureSecurity irFuture = new InterestRateFutureSecurity(expiry, tradingExchange, settlementExchange, currency, unitAmount, underlyingId, category);
Counterparty counterparty = new SimpleCounterparty(ExternalId.of(Counterparty.DEFAULT_SCHEME, "COUNTERPARTY"));
BigDecimal tradeQuantity = BigDecimal.valueOf(10);
LocalDate tradeDate = LocalDate.of(2000, 1, 1);
OffsetTime tradeTime = OffsetTime.of(LocalTime.of(0, 0), ZoneOffset.UTC);
SimpleTrade trade = new SimpleTrade(irFuture, tradeQuantity, counterparty, tradeDate, tradeTime);
TradeWrapper<?> irs = new InterestRateFutureTrade(trade);
ImmutableTradeBundle bundleOverride = irs.getTradeBundle()
.toBuilder()
.counterparty(new SimpleCounterparty(ExternalId.of(Counterparty.DEFAULT_SCHEME, "new counterparty")))
.build();
TradeWrapper<?> updatedIrs = irs.updateBundle(bundleOverride);
assertTrue(updatedIrs.getSecurity() == irs.getSecurity());
String newValue = updatedIrs.getTradeBundle().getCounterparty().getExternalId().getValue();
String oldValue = irs.getTradeBundle().getCounterparty().getExternalId().getValue();
assertEquals(newValue, "new counterparty");
assertEquals(oldValue, "COUNTERPARTY");
}
示例14: createDeliverableSwapFutureTrade
import org.threeten.bp.OffsetTime; //导入方法依赖的package包/类
private static DeliverableSwapFutureTrade createDeliverableSwapFutureTrade() {
Expiry expiry = new Expiry(ZonedDateTime.of(LocalDateTime.of(LocalDate.of(2014, 6, 15),
LocalTime.of(0, 0)),
ZoneOffset.UTC));
DeliverableSwapFutureSecurity dsf = new DeliverableSwapFutureSecurity(expiry,
Currency.USD + "DSF",
Currency.USD + "DSF",
Currency.USD,
1000,
"DSF",
UNDERLYING_SWAP.getExternalIdBundle().
getExternalIds().first(),
1);
String dsfId = Currency.USD + "_TestDSF";
ExternalIdBundle externalDsfBundle = ExternalSchemes.syntheticSecurityId(dsfId).toBundle();
dsf.setName(dsfId);
dsf.setExternalIdBundle(externalDsfBundle);
Counterparty counterparty = new SimpleCounterparty(ExternalId.of(Counterparty.DEFAULT_SCHEME, "COUNTERPARTY"));
OffsetTime tradeTime = OffsetTime.of(LocalTime.of(0, 0), ZoneOffset.UTC);
BigDecimal tradeQuantity = BigDecimal.valueOf(1);
SimpleTrade trade = new SimpleTrade(dsf, tradeQuantity, counterparty , TRADE_DATE, tradeTime);
trade.setPremium(0.0);
return new DeliverableSwapFutureTrade(trade);
}
示例15: createBondFutureTrade
import org.threeten.bp.OffsetTime; //导入方法依赖的package包/类
public static BondFutureTrade createBondFutureTrade() {
Counterparty counterparty = new SimpleCounterparty(ExternalId.of(Counterparty.DEFAULT_SCHEME, "COUNTERPARTY"));
BigDecimal tradeQuantity = BigDecimal.valueOf(1);
LocalDate tradeDate = LocalDate.of(2000, 1, 1);
OffsetTime tradeTime = OffsetTime.of(LocalTime.of(0, 0), ZoneOffset.UTC);
SimpleTrade trade = new SimpleTrade(createBondFutureSecurity(), tradeQuantity, counterparty, tradeDate, tradeTime);
trade.setPremium(0.0);
trade.setPremiumCurrency(Currency.JPY);
return new BondFutureTrade(trade);
}