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


Java DateTimeFormatter.ofPattern方法代码示例

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


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

示例1: RxBindingExampleViewModel

import org.threeten.bp.format.DateTimeFormatter; //导入方法依赖的package包/类
@Inject
public RxBindingExampleViewModel() {
    final long intervalMs = 10;
    final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("mm:ss:SS");

    timeStream = Observable
            .interval(intervalMs, TimeUnit.MILLISECONDS)
            .onBackpressureDrop()
            .map(beats -> Duration.ofMillis(intervalMs * beats))
            .map(duration -> formatter.format(LocalTime.MIDNIGHT.plus(duration)));

    calculateSubject = PublishSubject.create();
    highLoadStream = calculateSubject
            .observeOn(Schedulers.computation())
            .scan((sum, value) -> ++sum)
            .map(iteration -> {
                // Simulate high processing load
                try {
                    Thread.sleep(1000);
                }
                catch (InterruptedException e) {}
                return iteration;
            });
}
 
开发者ID:futurice,项目名称:android-rxmvvmdi,代码行数:25,代码来源:RxBindingExampleViewModel.java

示例2: generateEquityOptionTicker

import org.threeten.bp.format.DateTimeFormatter; //导入方法依赖的package包/类
/**
 * Generates an equity option ticker from details about the option.
 * 
 * @param underlyingTicker the ticker of the underlying equity, not null
 * @param expiry the option expiry, not null
 * @param optionType the option type, not null
 * @param strike the strike rate
 * @return the equity option ticker, not null
 */
public static ExternalId generateEquityOptionTicker(final String underlyingTicker, final Expiry expiry, final OptionType optionType, final double strike) {
  ArgumentChecker.notNull(underlyingTicker, "underlyingTicker");
  ArgumentChecker.notNull(expiry, "expiry");
  ArgumentChecker.notNull(optionType, "optionType");
  Pair<String, String> tickerMarketSectorPair = splitTickerAtMarketSector(underlyingTicker);
  DateTimeFormatter expiryFormatter = DateTimeFormatter.ofPattern("MM/dd/yy");
  DecimalFormat strikeFormat = new DecimalFormat("0.###");
  String strikeString = strikeFormat.format(strike);
  StringBuilder sb = new StringBuilder();
  sb.append(tickerMarketSectorPair.getFirst())
      .append(' ')
      .append(expiry.getExpiry().toString(expiryFormatter))
      .append(' ')
      .append(optionType == OptionType.PUT ? 'P' : 'C')
      .append(strikeString)
      .append(' ')
      .append(tickerMarketSectorPair.getSecond());
  return ExternalId.of(ExternalSchemes.BLOOMBERG_TICKER, sb.toString());
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:29,代码来源:BloombergDataUtils.java

示例3: setBeginDate

import org.threeten.bp.format.DateTimeFormatter; //导入方法依赖的package包/类
public void setBeginDate(String date)
{
    if (date.length()==16) date=date.concat(":00");
    if (date.length()>19) date=date.substring(0,19);
    DateTimeFormatter sf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
    begin= LocalDateTime.parse(date, sf);
    //Log.d("begindate",begin.toString());
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:9,代码来源:AbstractsxObject.java

示例4: setEndDate

import org.threeten.bp.format.DateTimeFormatter; //导入方法依赖的package包/类
public void setEndDate(String date)
{
    if (date.length()==16) date=date.concat(":00");
    if (date.length()>19) date=date.substring(0,19);
    DateTimeFormatter sf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
    end=LocalDateTime.parse(date, sf);
    //Log.d("enddate",end.toString());
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:9,代码来源:AbstractsxObject.java

示例5: formatDateTime

import org.threeten.bp.format.DateTimeFormatter; //导入方法依赖的package包/类
private String formatDateTime(Context context, LocalDateTime dateTime) {
    String dayPattern = context.getString(R.string.schedule_pager_day_pattern);
    DateTimeFormatter dayFormatter = DateTimeFormatter.ofPattern(dayPattern, Locale.getDefault());
    DateTimeFormatter timeFormatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT);

    String formatted = context.getString(R.string.schedule_browse_sessions_title_pattern,
            dateTime.format(dayFormatter),
            dateTime.format(timeFormatter));
    return Strings.capitalizeFirstLetter(formatted);
}
 
开发者ID:Nilhcem,项目名称:droidconde-2016,代码行数:11,代码来源:SessionsListPresenter.java

示例6: setNextddl

import org.threeten.bp.format.DateTimeFormatter; //导入方法依赖的package包/类
public void setNextddl(String date){
    DateTimeFormatter sf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
    nextddl= LocalDateTime.parse(date, sf);
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:5,代码来源:Habit.java

示例7: getPageTitle

import org.threeten.bp.format.DateTimeFormatter; //导入方法依赖的package包/类
@Override
public CharSequence getPageTitle(int position) {
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dayPattern, Locale.getDefault());
    return schedule.get(position).getDay().format(formatter);
}
 
开发者ID:Nilhcem,项目名称:droidcontn-2016,代码行数:6,代码来源:SchedulePagerAdapter.java

示例8: getShotDetailsDate

import org.threeten.bp.format.DateTimeFormatter; //导入方法依赖的package包/类
public static String getShotDetailsDate(ZonedDateTime date) {
    DateTimeFormatter formatter = DateTimeFormatter
            .ofPattern(SHOT_DETAILS_FORMAT);
    return date.format(formatter);
}
 
开发者ID:netguru,项目名称:inbbbox-android,代码行数:6,代码来源:DateTimeFormatUtil.java

示例9: getCurrentDate

import org.threeten.bp.format.DateTimeFormatter; //导入方法依赖的package包/类
public static String getCurrentDate() {
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_PATTERN);
    return ZonedDateTime.now().format(formatter);
}
 
开发者ID:netguru,项目名称:inbbbox-android,代码行数:5,代码来源:DateTimeFormatUtil.java

示例10: RowParser

import org.threeten.bp.format.DateTimeFormatter; //导入方法依赖的package包/类
protected RowParser() {
  _csvDateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
  _secondaryCsvDateFormatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
  _outputDateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:6,代码来源:RowParser.java

示例11: printTest

import org.threeten.bp.format.DateTimeFormatter; //导入方法依赖的package包/类
/**
 * This generates a table in the CDS pricing paper 
 */
@Test(enabled = false)
public void printTest() {
  final LocalDate tradeDate = LocalDate.of(2013, Month.JULY, 30);
  final Period tenor = Period.ofYears(2);
  final LocalDate stepIn = tradeDate.plusDays(1);
  final LocalDate startDate = getPrevIMMDate(stepIn);
  final LocalDate endDate = getNextIMMDate(tradeDate).plus(tenor);
  final Period paymentInt = Period.ofMonths(3);
  final StubType stub = StubType.FRONTSHORT;
  final double notional = 1e7;
  final double coupon = 1e-2;

  final ISDAPremiumLegSchedule schedule = new ISDAPremiumLegSchedule(startDate, endDate, paymentInt, stub, FOLLOWING, CALENDAR, true);

  final DateTimeFormatter formatt = DateTimeFormatter.ofPattern("dd-MMM-yy");

  final int n = schedule.getNumPayments();

  System.out.println("\\begin{tabular}{|c|c|c|c|c|}");
  System.out.println("\\hline");
  System.out.println("Accrual Start & Accrual End & Payment Date & Days in & Amount" + " \\\\");
  System.out.println("(Inclusive) & (Exclusive) &  & Period & " + " \\\\");
  System.out.println("\\hline");
  for (int i = 0; i < n; i++) {
    final LocalDate start = schedule.getAccStartDate(i);
    final LocalDate end = schedule.getAccEndDate(i);
    System.out.print(start.toString(formatt) + " & ");
    System.out.print(end.toString(formatt) + " & ");
    System.out.print(schedule.getPaymentDate(i).toString(formatt) + " & ");

    final long firstJulianDate = start.getLong(JulianFields.MODIFIED_JULIAN_DAY);
    final long secondJulianDate = end.getLong(JulianFields.MODIFIED_JULIAN_DAY);
    final int days = (int) (secondJulianDate - firstJulianDate);
    System.out.print(days + " & ");
    final double premium = notional * coupon * ACT360.getDayCountFraction(start, end);
    System.out.format("%.2f" + " \\\\" + "\n", premium);
  }
  System.out.println("\\hline");
  System.out.println("\\end{tabular}");
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:44,代码来源:ISDAPremiumLegScheduleTest.java

示例12: factory_parse_formatter

import org.threeten.bp.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test
public void factory_parse_formatter() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("u M d H m s VV");
    ZonedDateTime test = ZonedDateTime.parse("2010 12 3 11 30 0 Europe/London", f);
    assertEquals(test, ZonedDateTime.of(LocalDateTime.of(2010, 12, 3, 11, 30), ZoneId.of("Europe/London")));
}
 
开发者ID:ThreeTen,项目名称:threetenbp,代码行数:7,代码来源:TestZonedDateTime.java

示例13: factory_parse_formatter_nullText

import org.threeten.bp.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullText() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s");
    ZonedDateTime.parse((String) null, f);
}
 
开发者ID:ThreeTen,项目名称:threetenbp,代码行数:6,代码来源:TestZonedDateTime.java

示例14: test_format_formatter

import org.threeten.bp.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test
public void test_format_formatter() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s");
    String t = ZonedDateTime.of(dateTime(2010, 12, 3, 11, 30), ZONE_PARIS).format(f);
    assertEquals(t, "2010 12 3 11 30 0");
}
 
开发者ID:ThreeTen,项目名称:threetenbp,代码行数:7,代码来源:TestZonedDateTime.java

示例15: factory_parse_formatter

import org.threeten.bp.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test
public void factory_parse_formatter() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("u M d H m s");
    LocalDateTime test = LocalDateTime.parse("2010 12 3 11 30 45", f);
    assertEquals(test, LocalDateTime.of(2010, 12, 3, 11, 30, 45));
}
 
开发者ID:ThreeTen,项目名称:threetenbp,代码行数:7,代码来源:TestLocalDateTime.java


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