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


Java LocalTime.of方法代码示例

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


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

示例1: createDialog

import org.threeten.bp.LocalTime; //导入方法依赖的package包/类
/**
 * Creates a {@link TimePickerDialog} instance.
 *
 * @param context   to retrieve the time format (12 or 24 hour)
 * @param localTime the initial localTime
 * @param listener  to listen for a localTime selection
 * @param clock     to retrieve the calendar from
 * @return a new instance of {@link TimePickerDialog}
 */
@NonNull
public static TimePickerDialog createDialog(@NonNull Context context, @Nullable LocalTime localTime,
                                            @Nullable Consumer<LocalTime> listener, @NonNull Clock clock) {
  TimePickerDialog.OnTimeSetListener dialogCallBack = (view, hourOfDay, minute, second) -> {
    LocalTime time = LocalTime.of(hourOfDay, minute, second);
    Optional.ofNullable(listener)
        .ifPresent(theListener -> theListener.accept(time));
  };

  localTime = Optional.ofNullable(localTime)
      .orElse(LocalTime.now(clock));
  TimePickerDialog timePickerDialog = TimePickerDialog.newInstance(
      dialogCallBack,
      localTime.getHour(),
      localTime.getMinute(),
      localTime.getSecond(),
      DateFormat.is24HourFormat(context)
  );
  timePickerDialog.dismissOnPause(true);
  return timePickerDialog;
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:31,代码来源:TimePickerDialogHelper.java

示例2: testSerialisation

import org.threeten.bp.LocalTime; //导入方法依赖的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"));
}
 
开发者ID:gkopff,项目名称:gson-threeten-serialisers,代码行数:29,代码来源:ConvertersTest.java

示例3: correctDateToLocalTime

import org.threeten.bp.LocalTime; //导入方法依赖的package包/类
@Test
public void correctDateToLocalTime() {
  LocalTime expectedLocalTime = LocalTime.of(10, 10, 10);
  Calendar calendar = Calendar.getInstance();
  calendar.set(2017, Calendar.APRIL, 10, 10, 10, 10);
  calendar.set(Calendar.MILLISECOND, 0);
  Date date = calendar.getTime();

  LocalTime actualLocalTime = DateHelper.dateToLocalTime(date);
  assertThat(actualLocalTime, equalTo(expectedLocalTime));
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:12,代码来源:DateHelperTest.java

示例4: addLiborConventions

import org.threeten.bp.LocalTime; //导入方法依赖的package包/类
protected void addLiborConventions(final ConventionMaster master) {
  final String liborConventionName = getConventionName(ZAR, JIBOR);
  final IborIndexConvention liborConvention = new IborIndexConvention(
      liborConventionName, getIds(ZAR, JIBOR), ACT_365, FOLLOWING, 2, false, ZAR,
      LocalTime.of(11, 00), "ZA", ZA, ZA, "");
  addConvention(master, liborConvention);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:8,代码来源:ZAConventions.java

示例5: addIborIndexConvention

import org.threeten.bp.LocalTime; //导入方法依赖的package包/类
protected void addIborIndexConvention(final ConventionMaster master) {
  final String liborConventionName = getConventionName(Currency.CHF, LIBOR);
  final IborIndexConvention liborIndex = new IborIndexConvention(
      liborConventionName, getIds(Currency.CHF, LIBOR), ACT_360, MODIFIED_FOLLOWING, 2, true, Currency.CHF,
      LocalTime.of(11, 00), "CH", CHGB, CH, "");
  addConvention(master, liborIndex);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:8,代码来源:CHConventions.java

示例6: testIborIndexConvention

import org.threeten.bp.LocalTime; //导入方法依赖的package包/类
@Test
public void testIborIndexConvention() {
  final IborIndexConvention convention = new IborIndexConvention("EUR Deposit", ExternalIdBundle.of(InMemoryConventionBundleMaster.simpleNameSecurityId("EUR Deposit")),
      DayCounts.ACT_365, BusinessDayConventions.FOLLOWING, 2, true,
      Currency.EUR, LocalTime.of(11, 0), "EU", ExternalId.of("Test", "EU"), ExternalId.of("Test", "EU"), "Page");
  convention.setUniqueId(UniqueId.of("Test", "1234567"));
  assertEncodeDecodeCycle(IborIndexConvention.class, convention);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:9,代码来源:ConventionBuildersTest.java

示例7: testSwapIndexConvention

import org.threeten.bp.LocalTime; //导入方法依赖的package包/类
@Test
public void testSwapIndexConvention() {
  final SwapIndexConvention convention = new SwapIndexConvention("EUR 3m Swap", ExternalIdBundle.of(InMemoryConventionBundleMaster.simpleNameSecurityId("EUR 3m Swap")),
      LocalTime.of(11, 0), ExternalId.of("Test", "EUR 3m Swap"));
  convention.setUniqueId(UniqueId.of("Test", "12345"));
  assertEncodeDecodeCycle(SwapIndexConvention.class, convention);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:8,代码来源:ConventionBuildersTest.java

示例8: validateAndGetNullableDateField

import org.threeten.bp.LocalTime; //导入方法依赖的package包/类
private ZonedDateTime validateAndGetNullableDateField(final FudgeMsg fieldData, final String fieldName) {
  if (!isValidField(fieldData.getString(fieldName))) {
    return null;
  }
  // These will need to be sorted out.
  final LocalTime expiryTime = LocalTime.of(17, 00);
  final ZoneId zone = ZoneOffset.UTC;

  final LocalDate localDate = LocalDate.parse(fieldData.getString(fieldName));
  return localDate.atTime(expiryTime).atZone(zone);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:12,代码来源:BondLoader.java

示例9: testDeserialisation

import org.threeten.bp.LocalTime; //导入方法依赖的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));
}
 
开发者ID:gkopff,项目名称:gson-threeten-serialisers,代码行数:38,代码来源:ConvertersTest.java

示例10: getLocalTime

import org.threeten.bp.LocalTime; //导入方法依赖的package包/类
private static LocalTime getLocalTime(int hour, int minute) {
    return LocalTime.of(hour, minute, 0);
}
 
开发者ID:netguru,项目名称:inbbbox-android,代码行数:4,代码来源:DateTimeFormatUtil.java

示例11: init

import org.threeten.bp.LocalTime; //导入方法依赖的package包/类
@Override
public void init(final ConventionMaster master) {
  final String tenorString = "6M";
  // Index (Overnight and Ibor-like)
  final String onIndexName = getConventionName(Currency.JPY, OVERNIGHT);
  final ExternalId onIndexId = ExternalId.of(SCHEME_NAME, onIndexName);
  final OvernightIndexConvention onIndex = new OvernightIndexConvention(
      onIndexName, getIds(Currency.JPY, OVERNIGHT), ACT_365, 1, Currency.JPY, JP);
  final String iborConventionName = getConventionName(Currency.JPY, LIBOR);
  final IborIndexConvention liborIndex = new IborIndexConvention(
      iborConventionName, getIds(Currency.JPY, LIBOR), ACT_360, MODIFIED_FOLLOWING, 2, true, Currency.JPY,
      LocalTime.of(11, 00), "JP", JPGB, JP, "");
  final ExternalId liborConventionId = ExternalId.of(SCHEME_NAME, iborConventionName);
  final IborIndexConvention tiborJPIndex = new IborIndexConvention(
      getConventionName(Currency.JPY, TIBOR_JAPANESE), getIds(Currency.JPY, TIBOR_JAPANESE), ACT_365, MODIFIED_FOLLOWING, 2, true, Currency.JPY,
      LocalTime.of(11, 00), "JP", JP, JP, "");
  final IborIndexConvention tiborEuIndex = new IborIndexConvention(
      getConventionName(Currency.JPY, TIBOR_EUROYEN), getIds(Currency.JPY, TIBOR_EUROYEN), ACT_360, MODIFIED_FOLLOWING, 2, true, Currency.JPY,
      LocalTime.of(11, 00), "JP", JP, JP, "");
  // Deposit
  final String depositONConventionName = getConventionName(Currency.JPY, DEPOSIT_ON);
  final DepositConvention depositONConvention = new DepositConvention(
      depositONConventionName, getIds(Currency.JPY, DEPOSIT_ON), ACT_365, FOLLOWING, 0, false, Currency.JPY, JP);
  final String depositConventionName = getConventionName(Currency.JPY, DEPOSIT);
  final DepositConvention depositConvention = new DepositConvention(
      depositConventionName, getIds(Currency.JPY, DEPOSIT), ACT_365, FOLLOWING, 2, false, Currency.JPY, JP);
  // OIS legs
  final String oisFixedLegConventionName = getConventionName(Currency.JPY, OIS_FIXED_LEG);
  final String oisFloatLegConventionName = getConventionName(Currency.JPY, OIS_ON_LEG);
  final SwapFixedLegConvention oisFixedLegConvention = new SwapFixedLegConvention(
      oisFixedLegConventionName, getIds(Currency.JPY, OIS_FIXED_LEG),
      Tenor.ONE_YEAR, ACT_365, MODIFIED_FOLLOWING, Currency.JPY, JP, 2, true, StubType.SHORT_START, false, 2);
  final OISLegConvention oisFloatLegConvention = new OISLegConvention(
      oisFloatLegConventionName, getIds(Currency.JPY, OIS_ON_LEG), onIndexId,
      Tenor.ONE_YEAR, MODIFIED_FOLLOWING, 2, true, StubType.NONE, false, 2);
  // Ibor swap legs
  final String irsFixedLegConventionName = getConventionName(Currency.JPY, IRS_FIXED_LEG);
  final String irsIborLegConventionName = getConventionName(Currency.JPY, tenorString, IRS_IBOR_LEG);
  final SwapFixedLegConvention irsFixedLegConvention = new SwapFixedLegConvention(
      irsFixedLegConventionName, getIds(Currency.JPY, IRS_FIXED_LEG),
      Tenor.SIX_MONTHS, ACT_365, MODIFIED_FOLLOWING, Currency.JPY, JP, 2, true, StubType.SHORT_START, false, 2);
  final VanillaIborLegConvention irsIborLegConvention = new VanillaIborLegConvention(
      irsIborLegConventionName, getIds(Currency.JPY, tenorString, IRS_IBOR_LEG),
      liborConventionId, true, Interpolator1DFactory.LINEAR, Tenor.SIX_MONTHS, 2, true, StubType.NONE, false, 2);
  // X-Ccy OIS
  final OISLegConvention oisXCcyUSDLegConvention = new OISLegConvention(
      OIS_USD_JPY_ON_LEG, getIds(OIS_USD_JPY_ON_LEG), onIndexId,
      Tenor.THREE_MONTHS, MODIFIED_FOLLOWING, 2, true, StubType.NONE, false, 2);
  
  // Convention add
  addConvention(master, onIndex);
  addConvention(master, liborIndex);
  addConvention(master, tiborJPIndex);
  addConvention(master, tiborEuIndex);
  addConvention(master, depositONConvention);
  addConvention(master, depositConvention);
  addConvention(master, oisFixedLegConvention);
  addConvention(master, oisFloatLegConvention);
  addConvention(master, irsFixedLegConvention);
  addConvention(master, irsIborLegConvention);
  addConvention(master, oisXCcyUSDLegConvention);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:63,代码来源:JPConventions.java

示例12: createIborIndexConvention

import org.threeten.bp.LocalTime; //导入方法依赖的package包/类
protected IborIndexConvention createIborIndexConvention(final String bbswConventionName) {
  return new IborIndexConvention(
      bbswConventionName, getIds(Currency.AUD, BBSW), ACT_365, MODIFIED_FOLLOWING, 0, true, Currency.AUD,
      LocalTime.of(11, 00), "AU", AU, AU, "");
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:6,代码来源:AUConventions.java

示例13: createIborIndexConvention

import org.threeten.bp.LocalTime; //导入方法依赖的package包/类
protected IborIndexConvention createIborIndexConvention(final String bbswConventionName) {
  return new IborIndexConvention(
      bbswConventionName, getIds(CCY, CDOR), ACT_365, MODIFIED_FOLLOWING, 0, true, CCY,
      LocalTime.of(10, 00), "CA", CA, CA, "");
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:6,代码来源:CAConventions.java

示例14: mockConventionSource

import org.threeten.bp.LocalTime; //导入方法依赖的package包/类
private static ConventionSource mockConventionSource() {
  BusinessDayConvention following = BusinessDayConventions.FOLLOWING;
  DayCount act360 = DayCounts.ACT_360;
  StubType noStub = StubType.NONE;

  ConventionMaster master = new InMemoryConventionMaster();
  ConventionSource mock = mock(ConventionSource.class);
  when(mock.changeManager()).thenReturn(MOCK_CHANGE_MANAGER);

  SwapFixedLegConvention descPayLegConvention =
      new SwapFixedLegConvention(DISC_LEG_CONVENTION, _discPayLegConventionId.toBundle(), Tenor.ONE_YEAR,
                                 act360,
                                 BusinessDayConventions.MODIFIED_FOLLOWING, s_USD, s_USID, 2, true,
                                 StubType.SHORT_START, false, 2);
  descPayLegConvention.setUniqueId(UniqueId.of("CONV", "1"));
  master.add(new ConventionDocument(descPayLegConvention));

  OvernightIndexConvention onConvention =
      new OvernightIndexConvention(USD_OVERNIGHT_CONVENTION, _onConventionId.toBundle(), act360, 1, s_USD, s_USID);
  onConvention.setUniqueId(UniqueId.of("CONV", "2"));
  master.add(new ConventionDocument(onConvention));

  FederalFundsFutureConvention fffConvention =
      new FederalFundsFutureConvention(USD_FEDFUNDFUTURES_CONVENTION, _fffConventionId.toBundle(), 
          ExternalId.of("EXPIRY_CONVENTION", FedFundFutureAndFutureOptionMonthlyExpiryCalculator.NAME), 
          s_USID, ON_INDEX_ID, 5000000);
  fffConvention.setUniqueId(UniqueId.of("CONV", "3"));
  master.add(new ConventionDocument(fffConvention));

  OISLegConvention descReceiveLegConvention =
      new OISLegConvention(DISC_RECEIVE_LEG_CONVENTION, _discReceiveLegConventionId.toBundle(),
                           ON_INDEX_ID, Tenor.ONE_YEAR,
                           BusinessDayConventions.MODIFIED_FOLLOWING, 2, true, noStub, false, 2);
  descReceiveLegConvention.setUniqueId(UniqueId.of("CONV", "4"));
  master.add(new ConventionDocument(descReceiveLegConvention));


  DepositConvention descConvention =
      new DepositConvention(DISC_CONVENTION, _discConventionId.toBundle(), act360, following, 0, false, s_USD, s_USID);
  descConvention.setUniqueId(UniqueId.of("CONV", "5"));
  master.add(new ConventionDocument(descConvention));
  master.add(new ConventionDocument(LIBOR_PAY_LEG_CONVENTION));


  VanillaIborLegConvention liborReceiveLegConvention =
      new VanillaIborLegConvention(LIBOR_RECEIVE_LEG_CONVENTION_NAME, _liborReceiveLegConventionId.toBundle(),
                                   LIBOR_INDEX_ID, true, "Linear", Tenor.THREE_MONTHS, 2, true,
                                   StubType.SHORT_START, false, 0);
  liborReceiveLegConvention.setUniqueId(UniqueId.of("CONV", "6"));
  master.add(new ConventionDocument(liborReceiveLegConvention));


  IborIndexConvention liborConvention =
      new IborIndexConvention(LIBOR_CONVENTION, _liborConventionId.toBundle(), act360,
                              BusinessDayConventions.MODIFIED_FOLLOWING, 2,
                              false, s_USD, LocalTime.of(11, 0), "Europe/London", s_USGBID, s_USID, "");
  liborConvention.setUniqueId(UniqueId.of("CONV", "7"));
  master.add(new ConventionDocument(liborConvention));


  // TODO - We have 2 ids for the same convention - we should try to converge them

  FederalFundsFutureConvention fedFundsFutureConvention =
      new FederalFundsFutureConvention(PerCurrencyConventionHelper.FED_FUNDS_FUTURE,
                                       ExternalIdBundle.of(ExternalId.of(SCHEME_NAME, FED_FUNDS_FUTURE)),
                                       ExternalId.of(ExchangeTradedInstrumentExpiryCalculator.SCHEME, FedFundFutureAndFutureOptionMonthlyExpiryCalculator.NAME),
                                       s_USID,
                                       ON_INDEX_ID,
                                       5000000);
  fedFundsFutureConvention.setUniqueId(UniqueId.of("CONV", "8"));
  master.add(new ConventionDocument(fedFundsFutureConvention));

  return new MasterConventionSource(master);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:75,代码来源:InterestRateMockSources.java

示例15: getDefaultStartTime

import org.threeten.bp.LocalTime; //导入方法依赖的package包/类
/**
 * @return A start time that will yield 0 for the rounded start time
 */
public static LocalTime getDefaultStartTime() {
    return LocalTime.of(0, 5);
}
 
开发者ID:jguerinet,项目名称:MyMartlet,代码行数:7,代码来源:ScheduleConverter.java


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