本文整理汇总了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;
}
示例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;
}
示例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);
}
});
}
示例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);
}
});
}
示例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;
});
}
示例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"));
}
示例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");
}
}
示例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;
}
示例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());
}
示例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();
}
示例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;
}
示例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());
}
示例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());
}
示例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);
}
示例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);
}