本文整理汇总了Java中org.threeten.bp.OffsetDateTime.now方法的典型用法代码示例。如果您正苦于以下问题:Java OffsetDateTime.now方法的具体用法?Java OffsetDateTime.now怎么用?Java OffsetDateTime.now使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.threeten.bp.OffsetDateTime
的用法示例。
在下文中一共展示了OffsetDateTime.now方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_addWithTwoTrades_addThenGet
import org.threeten.bp.OffsetDateTime; //导入方法依赖的package包/类
@Test
public void test_addWithTwoTrades_addThenGet() {
ManageablePosition position = new ManageablePosition(BigDecimal.valueOf(20), ExternalId.of("A", "B"));
OffsetDateTime offsetDateTime = OffsetDateTime.now();
position.getTrades().add(new ManageableTrade(BigDecimal.TEN, ExternalId.of("A", "B"), offsetDateTime.toLocalDate(), offsetDateTime.minusSeconds(600).toOffsetTime(), ExternalId.of("CPS", "CPV")));
position.getTrades().add(new ManageableTrade(BigDecimal.TEN, ExternalId.of("A", "C"), offsetDateTime.toLocalDate(), offsetDateTime.minusSeconds(500).toOffsetTime(), ExternalId.of("CPS", "CPV")));
PositionDocument doc = new PositionDocument();
doc.setPosition(position);
PositionDocument added = _posMaster.add(doc);
assertNotNull(added);
assertNotNull(added.getUniqueId());
PositionDocument fromDb = _posMaster.get(added.getUniqueId());
assertNotNull(fromDb);
assertNotNull(fromDb.getUniqueId());
assertEquals(added, fromDb);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:22,代码来源:ModifyPositionDbPositionMasterWorkerAddPositionTest.java
示例2: test_resolve_trade
import org.threeten.bp.OffsetDateTime; //导入方法依赖的package包/类
public void test_resolve_trade() {
final OffsetDateTime now = OffsetDateTime.now();
final InMemorySecuritySource secSource = new InMemorySecuritySource();
final MockPositionSource posSource = new MockPositionSource();
final SimplePortfolio portfolio = new SimplePortfolio(UniqueId.of("Test", "1"), "Name");
final SimplePosition position = new SimplePosition(UniqueId.of("Test", "1"), new BigDecimal(1), ExternalIdBundle.EMPTY);
final SimpleTrade trade = new SimpleTrade(new SimpleSecurityLink(), new BigDecimal(1), new SimpleCounterparty(ExternalId.of("CPARTY", "C100")), now.toLocalDate(), now.toOffsetTime());
trade.setUniqueId(UniqueId.of("TradeScheme", "1"));
position.addTrade(trade);
portfolio.getRootNode().addPosition(position);
posSource.addPortfolio(portfolio);
final DefaultComputationTargetResolver test = new DefaultComputationTargetResolver(secSource, posSource);
final ComputationTargetSpecification spec = ComputationTargetSpecification.of(trade);
final ComputationTarget expected = new ComputationTarget(ComputationTargetType.TRADE, trade);
assertExpected(expected, test.resolve(spec, VersionCorrection.LATEST));
}
示例3: test_getTrade
import org.threeten.bp.OffsetDateTime; //导入方法依赖的package包/类
public void test_getTrade() throws Exception {
final PortfolioMaster mockPortfolio = mock(PortfolioMaster.class);
final PositionMaster mockPosition = mock(PositionMaster.class);
final OffsetDateTime now = OffsetDateTime.now();
final ManageableTrade doc = new ManageableTrade(BigDecimal.TEN, ExternalId.of("B", "C"), now.toLocalDate(), now.toOffsetTime().minusSeconds(100), ExternalId.of("CPARTY", "C100"));
doc.setUniqueId(UID);
when(mockPosition.getTrade(UID)).thenReturn(doc);
MasterPositionSource test = new MasterPositionSource(mockPortfolio, mockPosition);
Trade testResult = test.getTrade(UID);
verify(mockPosition, times(1)).getTrade(UID);
assertEquals(UID, testResult.getUniqueId());
assertEquals(BigDecimal.TEN, testResult.getQuantity());
assertEquals(ExternalId.of("B", "C").toBundle(), testResult.getSecurityLink().getExternalId());
}
示例4: test_addWithTwoTrades_add
import org.threeten.bp.OffsetDateTime; //导入方法依赖的package包/类
@Test
public void test_addWithTwoTrades_add() {
Instant now = Instant.now(_posMaster.getClock());
OffsetDateTime offsetDateTime = OffsetDateTime.now();
ManageablePosition position = new ManageablePosition(BigDecimal.TEN, ExternalId.of("A", "B"));
position.getTrades().add(new ManageableTrade(BigDecimal.TEN, ExternalId.of("A", "C"), offsetDateTime.toLocalDate(), offsetDateTime.minusSeconds(600).toOffsetTime(), ExternalId.of("CPS", "CPV")));
position.getTrades().add(new ManageableTrade(BigDecimal.TEN, ExternalId.of("A", "D"), offsetDateTime.toLocalDate(), offsetDateTime.minusSeconds(500).toOffsetTime(), ExternalId.of("CPS", "CPV")));
PositionDocument doc = new PositionDocument();
doc.setPosition(position);
PositionDocument test = _posMaster.add(doc);
UniqueId portfolioId = test.getUniqueId();
assertNotNull(portfolioId);
assertEquals("DbPos", portfolioId.getScheme());
assertTrue(portfolioId.isVersioned());
assertTrue(Long.parseLong(portfolioId.getValue()) >= 1000);
assertEquals("0", portfolioId.getVersion());
assertEquals(now, test.getVersionFromInstant());
assertEquals(null, test.getVersionToInstant());
assertEquals(now, test.getCorrectionFromInstant());
assertEquals(null, test.getCorrectionToInstant());
ManageablePosition testPosition = test.getPosition();
assertNotNull(testPosition);
assertEquals(portfolioId, testPosition.getUniqueId());
assertEquals(BigDecimal.TEN, testPosition.getQuantity());
ExternalIdBundle secKey = testPosition.getSecurityLink().getExternalId();
assertEquals(1, secKey.size());
assertTrue(secKey.getExternalIds().contains(ExternalId.of("A", "B")));
assertNotNull(testPosition.getTrades());
assertTrue(testPosition.getTrades().size() == 2);
for (ManageableTrade testTrade : testPosition.getTrades()) {
assertNotNull(testTrade);
UniqueId tradeId = testTrade.getUniqueId();
assertNotNull(tradeId);
assertEquals("DbPos", portfolioId.getScheme());
assertTrue(portfolioId.isVersioned());
assertTrue(Long.parseLong(portfolioId.getValue()) >= 1000);
assertEquals("0", portfolioId.getVersion());
}
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:45,代码来源:ModifyPositionDbPositionMasterWorkerAddPositionTest.java
示例5: init
import org.threeten.bp.OffsetDateTime; //导入方法依赖的package包/类
private void init() {
_prtMaster = new DbPortfolioMaster(getDbConnector());
_now = OffsetDateTime.now();
_prtMaster.setClock(Clock.fixed(_now.toInstant(), ZoneOffset.UTC));
_version1Instant = _now.toInstant().minusSeconds(100);
_version2Instant = _now.toInstant().minusSeconds(50);
s_logger.debug("test data now: {}", _version1Instant);
s_logger.debug("test data later: {}", _version2Instant);
final JdbcOperations template = _prtMaster.getDbConnector().getJdbcOperations();
template.update("INSERT INTO prt_portfolio VALUES (?,?,?,?,?, ?,?,?)",
101, 101, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, "TestPortfolio101", 25);
template.update("INSERT INTO prt_portfolio VALUES (?,?,?,?,?, ?,?,?)",
102, 102, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, "TestPortfolio102", 25);
template.update("INSERT INTO prt_portfolio VALUES (?,?,?,?,?, ?,?,?)",
201, 201, toSqlTimestamp(_version1Instant), toSqlTimestamp(_version2Instant), toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, "TestPortfolio201", 25);
template.update("INSERT INTO prt_portfolio VALUES (?,?,?,?,?, ?,?,?)",
202, 201, toSqlTimestamp(_version2Instant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version2Instant), MAX_SQL_TIMESTAMP, "TestPortfolio202", 25);
template.update("INSERT INTO prt_portfolio VALUES (?,?,?,?,?, ?,?,?)",
301, 301, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, "TestPortfolio301", 75);
_visiblePortfolios = 3;
_totalPortfolios = 4;
template.update("INSERT INTO prt_node VALUES (?,?,?,?,?, ?,?,?,?,?)",
111, 111, 101, 101, null, null, 0, 1, 6, "TestNode111");
template.update("INSERT INTO prt_node VALUES (?,?,?,?,?, ?,?,?,?,?)",
112, 112, 101, 101, 111, 111, 1, 2, 5, "TestNode112");
template.update("INSERT INTO prt_node VALUES (?,?,?,?,?, ?,?,?,?,?)",
113, 113, 101, 101, 112, 112, 2, 3, 4, "TestNode113");
template.update("INSERT INTO prt_node VALUES (?,?,?,?,?, ?,?,?,?,?)",
121, 121, 102, 102, null, null, 0, 1, 2, "TestNode121");
template.update("INSERT INTO prt_node VALUES (?,?,?,?,?, ?,?,?,?,?)",
211, 211, 201, 201, null, null, 0, 1, 2, "TestNode211");
template.update("INSERT INTO prt_node VALUES (?,?,?,?,?, ?,?,?,?,?)",
212, 211, 202, 201, null, null, 0, 1, 2, "TestNode212");
template.update("INSERT INTO prt_node VALUES (?,?,?,?,?, ?,?,?,?,?)",
311, 311, 301, 301, null, null, 0, 1, 2, "TestNode311");
template.update("INSERT INTO prt_position VALUES (?,?,?)",
112, "DbPos", "500");
template.update("INSERT INTO prt_position VALUES (?,?,?)",
113, "DbPos", "501");
template.update("INSERT INTO prt_position VALUES (?,?,?)",
113, "DbPos", "502");
template.update("INSERT INTO prt_position VALUES (?,?,?)",
211, "DbPos", "500");
template.update("INSERT INTO prt_position VALUES (?,?,?)",
212, "DbPos", "500");
template.update("INSERT INTO prt_position VALUES (?,?,?)",
311, "DbPos", "500");
template.update("INSERT INTO prt_portfolio_attribute VALUES (?,?,?,?,?)",
10, 101, 101, "K101a", "V101a");
template.update("INSERT INTO prt_portfolio_attribute VALUES (?,?,?,?,?)",
11, 101, 101, "K101b", "V101b");
template.update("INSERT INTO prt_portfolio_attribute VALUES (?,?,?,?,?)",
12, 102, 102, "K102a", "V102a");
template.update("INSERT INTO prt_portfolio_attribute VALUES (?,?,?,?,?)",
13, 102, 102, "K102b", "V102b");
_totalPositions = 6;
}