本文整理了Java中org.threeten.bp.format.DateTimeFormatter.format()
方法的一些代码示例,展示了DateTimeFormatter.format()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTimeFormatter.format()
方法的具体详情如下:
包路径:org.threeten.bp.format.DateTimeFormatter
类名称:DateTimeFormatter
方法名:format
[英]Formats a date-time object using this formatter.
This formats the date-time to a String using the rules of the formatter.
[中]使用此格式化程序格式化日期时间对象。
这将使用格式化程序的规则将日期时间格式化为字符串。
代码示例来源:origin: JakeWharton/u2020
@Override public String toString() {
// Returning null here is not ideal, but it lets retrofit drop the query param altogether.
return createdSince == null ? null : "created:>=" + ISO_LOCAL_DATE.format(createdSince);
}
代码示例来源:origin: prolificinteractive/material-calendarview
@Override
public void onDateSelected(
@NonNull MaterialCalendarView widget,
@NonNull CalendarDay date,
boolean selected) {
textView.setText(selected ? FORMATTER.format(date.getDate()) : "No Selection");
}
代码示例来源:origin: prolificinteractive/material-calendarview
@Override
public void onDateLongClick(@NonNull MaterialCalendarView widget, @NonNull CalendarDay date) {
final String text = String.format("%s is available", FORMATTER.format(date.getDate()));
Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
}
代码示例来源:origin: prolificinteractive/material-calendarview
@Override
public void onDateLongClick(@NonNull MaterialCalendarView widget, @NonNull CalendarDay date) {
final String text = String.format("%s is available", FORMATTER.format(date.getDate()));
Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
}
代码示例来源:origin: prolificinteractive/material-calendarview
/**
* {@inheritDoc}
*/
@Override @NonNull public String format(@NonNull final CalendarDay day) {
return dateFormat.format(day.getDate());
}
}
代码示例来源:origin: prolificinteractive/material-calendarview
@Override
public void onDateSelected(
@NonNull MaterialCalendarView widget,
@NonNull CalendarDay date,
boolean selected) {
textView.setText(FORMATTER.format(date.getDate()));
}
}
代码示例来源:origin: prolificinteractive/material-calendarview
/**
* {@inheritDoc}
*/
@Override public CharSequence format(final CalendarDay day) {
return dateFormat.format(day.getDate());
}
}
代码示例来源:origin: prolificinteractive/material-calendarview
@Override
public void onDateLongClick(@NonNull MaterialCalendarView widget, @NonNull CalendarDay date) {
Toast.makeText(this, FORMATTER.format(date.getDate()), Toast.LENGTH_SHORT).show();
}
}
代码示例来源:origin: prolificinteractive/material-calendarview
@Override public void onDateSelected(
@NonNull final MaterialCalendarView widget,
@NonNull final CalendarDay date,
final boolean selected) {
final String text = selected ? FORMATTER.format(date.getDate()) : "No Selection";
Toast.makeText(SelectionModesActivity.this, text, Toast.LENGTH_SHORT).show();
}
代码示例来源:origin: prolificinteractive/material-calendarview
@Override
public void onMonthChanged(MaterialCalendarView widget, CalendarDay date) {
//noinspection ConstantConditions
getSupportActionBar().setTitle(FORMATTER.format(date.getDate()));
}
}
代码示例来源:origin: prolificinteractive/material-calendarview
@Override
public void onMonthChanged(MaterialCalendarView widget, CalendarDay date) {
//noinspection ConstantConditions
getSupportActionBar().setTitle(FORMATTER.format(date.getDate()));
}
}
代码示例来源:origin: googleapis/google-cloud-java
case TIMESTAMP:
if (value instanceof Long) {
return timestampFormatter.format(Instant.ofEpochMilli(((Long) value) / 1000));
} else if (value instanceof String) {
代码示例来源:origin: googleapis/google-cloud-java
DateTimeFormatter.ISO_DATE_TIME
.withZone(ZoneOffset.UTC)
.format(Instant.ofEpochMilli(System.currentTimeMillis())));
if (projects.putIfAbsent(project.getProjectId(), project) != null) {
return Error.ALREADY_EXISTS.response(
代码示例来源:origin: googleapis/google-cloud-java
Change toPb() {
Change pb = new Change();
// set id
if (getGeneratedId() != null) {
pb.setId(getGeneratedId());
}
// set timestamp
if (getStartTimeMillis() != null) {
pb.setStartTime(
DateTimeFormatter.ISO_DATE_TIME
.withZone(ZoneOffset.UTC)
.format(Instant.ofEpochMilli(getStartTimeMillis())));
}
// set status
if (status() != null) {
pb.setStatus(status().name().toLowerCase());
}
// set a list of additions
pb.setAdditions(Lists.transform(getAdditions(), RecordSet.TO_PB_FUNCTION));
// set a list of deletions
pb.setDeletions(Lists.transform(getDeletions(), RecordSet.TO_PB_FUNCTION));
return pb;
}
代码示例来源:origin: googleapis/google-cloud-java
ManagedZone toPb() {
ManagedZone pb = new ManagedZone();
pb.setDescription(this.getDescription());
pb.setDnsName(this.getDnsName());
if (this.getGeneratedId() != null) {
pb.setId(new BigInteger(this.getGeneratedId()));
}
pb.setName(this.getName());
pb.setNameServers(this.nameServers); // do use real attribute value which may be null
pb.setNameServerSet(this.getNameServerSet());
if (this.getCreationTimeMillis() != null) {
pb.setCreationTime(
DATE_TIME_FORMATTER.format(Instant.ofEpochMilli(this.getCreationTimeMillis())));
}
return pb;
}
代码示例来源:origin: googleapis/google-cloud-java
com.google.api.services.cloudresourcemanager.model.Project toPb() {
com.google.api.services.cloudresourcemanager.model.Project projectPb =
new com.google.api.services.cloudresourcemanager.model.Project();
projectPb.setName(name);
projectPb.setProjectId(projectId);
projectPb.setLabels(labels);
projectPb.setProjectNumber(projectNumber);
if (state != null) {
projectPb.setLifecycleState(state.toString());
}
if (createTimeMillis != null) {
projectPb.setCreateTime(
DateTimeFormatter.ISO_DATE_TIME
.withZone(ZoneOffset.UTC)
.format(Instant.ofEpochMilli(createTimeMillis)));
}
if (parent != null) {
projectPb.setParent(parent.toPb());
}
return projectPb;
}
代码示例来源:origin: com.neotys.ascode/swagger-java-client
@Override
public void write(JsonWriter out, LocalDate date) throws IOException {
if (date == null) {
out.nullValue();
} else {
out.value(formatter.format(date));
}
}
代码示例来源:origin: de.adorsys.multibanking/finapi-adapter
@Override
public void write(JsonWriter out, OffsetDateTime date) throws IOException {
if (date == null) {
out.nullValue();
} else {
out.value(formatter.format(date));
}
}
代码示例来源:origin: jeffdcamp/dbtools-android
@Nullable
public static String localTimeToDBString(@Nullable LocalTime d) {
if (d != null) {
return DB_TIME_FORMATTER310.format(d);
} else {
return null;
}
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Outputs this date-time as a {@code String} using the formatter.
*
* @param formatter the formatter to use, not null
* @return the formatted date-time string, not null
* @throws DateTimeException if an error occurs during printing
*/
public String format(DateTimeFormatter formatter) {
Jdk8Methods.requireNonNull(formatter, "formatter");
return formatter.format(this);
}
内容来源于网络,如有侵权,请联系作者删除!