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


Java DateTimeFormatter类代码示例

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


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

示例1: newInfo

import org.threeten.bp.format.DateTimeFormatter; //导入依赖的package包/类
protected AccelerationData.Info newInfo(final Materialization materialization) {
  final com.dremio.service.accelerator.proto.JobDetails details = materialization.getJob();
  final Long jobStart = details.getJobStart();
  final Long jobEnd = details.getJobEnd();

  final AccelerationData.Info info = new AccelerationData.Info();
  if (jobStart != null) {
    info.setStart(DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.ofInstant(Instant.ofEpochMilli(jobStart), ZoneOffset.UTC)));
  }
  if (jobEnd != null) {
    info.setEnd(DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.ofInstant(Instant.ofEpochMilli(jobEnd), ZoneOffset.UTC)));
  }

  if (jobStart != null && jobEnd != null) {
    final Duration duration = Duration.ofMillis(jobEnd - jobStart);
    info.setDuration(DateTimeFormatter.ISO_LOCAL_TIME.format(LocalTime.MIDNIGHT.plus(duration)));
  }

  info.setJobId(details.getJobId())
    .setInputBytes(details.getInputBytes())
    .setInputRecords(details.getInputRecords())
    .setOutputBytes(details.getOutputBytes())
    .setOutputRecords(details.getOutputRecords());

  return info;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:27,代码来源:DatasetsResource.java

示例2: CustomInstantDeserializer

import org.threeten.bp.format.DateTimeFormatter; //导入依赖的package包/类
protected CustomInstantDeserializer(Class<T> supportedType,
                  DateTimeFormatter parser,
                  Function<TemporalAccessor, T> parsedToValue,
                  Function<FromIntegerArguments, T> fromMilliseconds,
                  Function<FromDecimalArguments, T> fromNanoseconds,
                  BiFunction<T, ZoneId, T> adjust) {
  super(supportedType, parser);
  this.parsedToValue = parsedToValue;
  this.fromMilliseconds = fromMilliseconds;
  this.fromNanoseconds = fromNanoseconds;
  this.adjust = adjust == null ? new BiFunction<T, ZoneId, T>() {
    @Override
    public T apply(T t, ZoneId zoneId) {
      return t;
    }
  } : adjust;
}
 
开发者ID:cliffano,项目名称:swaggy-jenkins,代码行数:18,代码来源:CustomInstantDeserializer.java

示例3: displayAlarms

import org.threeten.bp.format.DateTimeFormatter; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void displayAlarms(PrintStream writer) {
    sessionsDao.getSessions()
            .flatMap(Observable::from)
            .map(session -> {
                Intent intent = new ReminderReceiverIntentBuilder(session).build(context);
                PendingIntent broadcast = PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_NO_CREATE);
                if (broadcast != null) {
                    return String.format(Locale.US, "%s - Session(id=%d, title=%s)", session.getFromTime().format(DateTimeFormatter.ISO_DATE_TIME), session.getId(), session.getTitle());
                }
                return null;
            })
            .filter(id -> id != null)
            .toList()
            .subscribe(activeAlarms -> {
                writer.println(Integer.toString(activeAlarms.size()) + " active alarm(s)");
                for (String activeAlarm : activeAlarms) {
                    writer.println(activeAlarm);
                }
            });
}
 
开发者ID:Nilhcem,项目名称:droidconde-2016,代码行数:22,代码来源:AppDumperPlugin.java

示例4: displayAlarms

import org.threeten.bp.format.DateTimeFormatter; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void displayAlarms(PrintStream writer) {
    sessionsDao.getSessions()
            .flatMap(Observable::from)
            .map(session -> {
                Intent intent = new ReminderReceiverIntentBuilder(session.getId()).build(context);
                PendingIntent broadcast = PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_NO_CREATE);
                if (broadcast != null) {
                    return String.format(Locale.US, "%s - Session(id=%d, title=%s)", session.getFromTime().format(DateTimeFormatter.ISO_DATE_TIME), session.getId(), session.getTitle());
                }
                return null;
            })
            .filter(id -> id != null)
            .toList()
            .subscribe(activeAlarms -> {
                writer.println(Integer.toString(activeAlarms.size()) + " active alarm(s)");
                for (String activeAlarm : activeAlarms) {
                    writer.println(activeAlarm);
                }
            });
}
 
开发者ID:Nilhcem,项目名称:devfestnantes-2016,代码行数:22,代码来源:AppDumperPlugin.java

示例5: 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

示例6: fetchData

import org.threeten.bp.format.DateTimeFormatter; //导入依赖的package包/类
private void fetchData(Action0 termination) {
    this.tracker = this.wakatimeClient.fetchLastSevenDays(HeaderFormatter.get(realm))
        .observeOn(uiScheduler)
        .subscribeOn(ioScheduler)
        .map(Wrapper::getData)
        .doOnError(viewModel::notifyError)
        .doOnTerminate(termination)
        .subscribe(
            data -> {
                viewModel.setData(data);
                viewModel.setRotationCache(data);
            }, throwable -> Timber.e(throwable, "Error while fetching data")
        );

    this.durationTracker = this.wakatimeClient.fetchDurations(HeaderFormatter.get(realm),
        LocalDate.now().format(DateTimeFormatter.ISO_DATE))
        .observeOn(uiScheduler)
        .subscribeOn(ioScheduler)
        .map(DurationWrapper::getData)
        .map(this::sumDurations)
        .map(this::formatTime)
        .doOnError(err -> Timber.w(err, "Error during processing durations"))
        .onErrorReturn(error -> "Not available")
        .subscribe(time -> viewModel.setTodayTime(time), error ->
            Timber.w(error, "Error parsing time"));
}
 
开发者ID:omgitsjoao,项目名称:wakatime-android-client,代码行数:27,代码来源:DefaultLastSevenDaysPresenter.java

示例7: constructPortfolioReader

import org.threeten.bp.format.DateTimeFormatter; //导入依赖的package包/类
private static PositionReader constructPortfolioReader(String filename, SecurityProvider securityProvider, DateTimeFormatter dateFormatter) {
  InputStream stream;
  try {
    stream = new BufferedInputStream(new FileInputStream(filename));
  } catch (FileNotFoundException e) {
    throw new OpenGammaRuntimeException("Could not open file " + filename + " for reading: " + e);
  }
  
  SheetFormat sheetFormat = SheetFormat.of(filename);
  switch (sheetFormat) {
    case XLS:
    case CSV:
      // Check that the asset class was specified on the command line
      return new SingleSheetSimplePositionReader(sheetFormat, stream, new ExchangeTradedRowParser(securityProvider, dateFormatter));

    default:
      throw new OpenGammaRuntimeException("Input filename should end in .CSV or .XLS");
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:20,代码来源:ResolvingPortfolioLoaderTool.java

示例8: buildMockSheetReader

import org.threeten.bp.format.DateTimeFormatter; //导入依赖的package包/类
private SheetReader buildMockSheetReader(LocalDateDoubleTimeSeries lddts) { 
  
  DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
  builder.appendPattern(DATE_FORMAT);
  DateTimeFormatter dateFormat = builder.toFormatter();

  SheetReader mock = mock(SheetReader.class);
  OngoingStubbing<Map<String, String>> stub = when(mock.loadNextRow());
  for (Map.Entry<LocalDate, Double> entry : lddts) {
    Map<String, String> row = new HashMap<String, String>();
    row.put("id", EXISTING_HTSINFO_EXTERNALID.getValue());
    row.put("date", entry.getKey().toString(dateFormat));
    row.put("value", entry.getValue().toString());
    stub = stub.thenReturn(row);
  }
  stub.thenReturn(null);
  return mock;    
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:19,代码来源:TimeSeriesLoaderTest.java

示例9: 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

示例10: setUp

import org.threeten.bp.format.DateTimeFormatter; //导入依赖的package包/类
@BeforeMethod
public void setUp(Method m) throws Exception {
  MockReferenceDataProvider refDataProvider = new MockReferenceDataProvider();
  refDataProvider.addExpectedField("SECURITY_TYP");
  refDataProvider.addResult("QQQQ US Equity", "SECURITY_TYP", "ETP");
  refDataProvider.addResult("/buid/EQ0082335400001000", "SECURITY_TYP", "ETP");
  
  File watchListFile = new File(BloombergRefDataCollectorTest.class.getResource(WATCH_LIST_FILE).toURI());
  File fieldListFile = new File(BloombergRefDataCollectorTest.class.getResource(FIELD_LIST_FILE).toURI());
  
  String outfileName = getClass().getSimpleName() + "-" + Thread.currentThread().getName() +
      "-" + OffsetDateTime.now(ZoneOffset.UTC).toString(DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss'Z'"));
  
  _outputFile = File.createTempFile(outfileName, null);
  _outputFile.deleteOnExit();
  
  _refDataCollector = new BloombergRefDataCollector(s_fudgeContext, watchListFile, refDataProvider, fieldListFile, _outputFile);
  _refDataCollector.start();
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:20,代码来源:BloombergRefDataCollectorTest.java

示例11: createRootData

import org.threeten.bp.format.DateTimeFormatter; //导入依赖的package包/类
/**
 * Creates a new Freemarker root data.
 * <p>
 * This creates a new data object to be passed to Freemarker with some standard keys:
 * <ul>
 * <li>now - the current date-time using {@link OpenGammaClock}
 * <li>timeFormatter - a formatter that outputs the time as HH:mm:ss
 * <li>offsetFormatter - a formatter that outputs the time-zone offset
 * <li>homeUris - the home URIs
 * <li>baseUri - the base URI
 * <li>security - an instance of WebSecurity
 * </ul>
 * 
 * @param uriInfo  the URI information, not null
 * @return the root data, not null
 */
public static FlexiBean createRootData(UriInfo uriInfo) {
  FlexiBean out = FreemarkerOutputter.createRootData();
  out.put("homeUris", new WebHomeUris(uriInfo));
  out.put("baseUri", uriInfo.getBaseUri().toString());
  WebUser user = new WebUser(uriInfo);
  UserProfile profile = user.getProfile();
  if (profile != null) {
    Locale locale = profile.getLocale();
    ZoneId zone = profile.getZone();
    DateTimeFormatter dateFormatter = profile.getDateStyle().formatter(locale);
    DateTimeFormatter timeFormatter = profile.getTimeStyle().formatter(locale);
    ZonedDateTime now = ZonedDateTime.now(OpenGammaClock.getInstance().withZone(zone));
    out.put("now", now);
    out.put("locale", locale);
    out.put("timeZone", zone);
    out.put("dateFormatter", dateFormatter);
    out.put("timeFormatter", timeFormatter);
  }
  out.put("userSecurity", user);
  return out;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:38,代码来源:FreemarkerOutputter.java

示例12: 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

示例13: 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

示例14: startRTCWakeUpAlarm

import org.threeten.bp.format.DateTimeFormatter; //导入依赖的package包/类
public static void startRTCWakeUpAlarm(Context context, Class<?> cls, LocalDateTime date)
{
    // 获取AlarmManager系统服务
    Calendar c=getCalendar(date);
    Intent intent = new Intent(context, cls);
    intent.putExtra("date",date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));//向receiver发送还是用intent
    PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
    //设置一个PendingIntent对象,发送广播
    AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    alarm.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), pi);
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:12,代码来源:Alarmfunction.java

示例15: withDateFormat

import org.threeten.bp.format.DateTimeFormatter; //导入依赖的package包/类
@Override
protected JsonDeserializer<T> withDateFormat(DateTimeFormatter dtf) {
  if (dtf == _formatter) {
    return this;
  }
  return new CustomInstantDeserializer<T>(this, dtf);
}
 
开发者ID:cliffano,项目名称:swaggy-jenkins,代码行数:8,代码来源:CustomInstantDeserializer.java


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