本文整理汇总了Java中java.time.LocalDate.format方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDate.format方法的具体用法?Java LocalDate.format怎么用?Java LocalDate.format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.LocalDate
的用法示例。
在下文中一共展示了LocalDate.format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public ElementResult apply(EnvWithSubmitInfo env) {
Map<ElementContainer, ElementResult> childs =
env.getProcessor().processElements(env, day, month, year);
LocalDate dateValue = initialValue;
ValidationResult validationResult = ValidationResult.undefined();
String dateValStr = "";
if (env.isSubmitted()) {
try {
dateValue = this.setupValue(this.initialValue, childs.get(day).getValue(),
childs.get(month).getValue(), childs.get(year).getValue());
dateValStr = dateValue.format(DateTimeFormatter.ISO_DATE);
} catch (DateTimeException | NumberFormatException e) {
validationResult = ValidationResult.fail("jformchecker.wrong_date_format");
}
}
ElementResult result = new ElementResult(dateValStr,
new StaticElementInfo(name, getDefault(), 3), childs, dateValue);
if (validationResult != ValidationResult.undefined()) {
return result.cloneWithNewValidationResult(validationResult);
}
return result;
}
示例2: vanLocalDateNaarXsdDate
import java.time.LocalDate; //导入方法依赖的package包/类
/**
* @param localDate localDate
* @return xsd date
*/
public static String vanLocalDateNaarXsdDate(final LocalDate localDate) {
if (localDate == null) {
return null;
}
return localDate.format(DateTimeFormatter.ISO_DATE);
}
示例3: generateProductIncrementName
import java.time.LocalDate; //导入方法依赖的package包/类
private String generateProductIncrementName(int months){
String pattern = "%1s-%2s";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
LocalDate now = LocalDate.now();
LocalDate changeMonthDate = now.plusMonths(months);
String formattedChangeMonthDate = changeMonthDate.format(formatter);
String formattedNow = now.format(formatter);
return months < 0 ?
String.format(pattern,formattedChangeMonthDate,formattedNow) :
String.format(pattern,formattedNow ,formattedChangeMonthDate);
}
示例4: validDate
import java.time.LocalDate; //导入方法依赖的package包/类
/**
* Validates that the given value conforms to expected date formatting (i.e. yyyyMMdd).
*
* @param value to validate
* @return valid date String
* @throws EncodeException
*/
protected String validDate(String value) {
try {
LocalDate thisDate = LocalDate.parse(cleanString(value), DateTimeFormatter.ofPattern("yyyyMMdd"));
return thisDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
} catch (Exception e) {
throw new EncodeException(value + " is not an date of format YYYYMMDD.", e);
}
}
示例5: dateToString
import java.time.LocalDate; //导入方法依赖的package包/类
/**
* This method returns as {@link String} the {@link LocalDate} passed as parameter using by default JSKPatter.LOCAL_DATE_DEFAULT_FORMAT as formatter.
* @param date {@link LocalDate}
* @return {@link String}
* @throws JSKException if some of the parameters are null.
*/
public static String dateToString(LocalDate date) throws JSKException {
if (isNull(date)) {
throw new JSKException(NULL_PARAMETERS);
}
return date.format(LOCAL_DATE_DEFAULT_FORMAT);
}
示例6: Activity
import java.time.LocalDate; //导入方法依赖的package包/类
public Activity(String name, String details, LocalDate date, int duration, int activityQuantity, String type)
{
super(date.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + "T00:00:01Z");
this.setName(name);
this.setDetails(details);
this.duration = duration;
this.activityQuantity = activityQuantity;
this.type = QuantityType.get(type);
}
示例7: formatDate
import java.time.LocalDate; //导入方法依赖的package包/类
/**
* @param date
* @param formatterDate
* @return la date formatee
*/
public static String formatDate(LocalDate date, DateTimeFormatter formatterDate) {
if (date == null) {
return "";
} else {
return date.format(formatterDate);
}
}
示例8: downloadFund
import java.time.LocalDate; //导入方法依赖的package包/类
private File downloadFund(int fond) {
File xls = null;
LocalDate dateEnd = LocalDate.now();
LocalDate dateStart = dateEnd.minusYears(1);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String dateStartFormatted = dateStart.format(formatter);
String dateEndFormatted = dateEnd.format(formatter);
String url = URL_PATTERN.replace("{start}", dateStartFormatted)
.replace("{end}", dateEndFormatted)
.replace("{fond}", Integer.toString(fond));
try {
xls = File.createTempFile("baud-", ".xls");
xls.deleteOnExit();
URL xlsUrl = new URL(url);
ReadableByteChannel rbc = Channels.newChannel(xlsUrl.openStream());
FileOutputStream fos = new FileOutputStream(xls);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
} catch(Exception e) {
e.printStackTrace();
}
return xls;
}
示例9: LocalDateToString
import java.time.LocalDate; //导入方法依赖的package包/类
private static String LocalDateToString(LocalDate value)
{
return value.format(DateTimeFormatter.ofPattern("MM-dd"));
}
示例10: formatted
import java.time.LocalDate; //导入方法依赖的package包/类
private static String formatted(LocalDate date) {
return date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
示例11: onCreateView
import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.chart_frag, container, false);
// Set up timeline chart
chart = view.findViewById(R.id.timeline);
entries = new ArrayList<>();
// Set up the x-axis
XAxis xAxis = chart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
formatter = DateTimeFormatter.ofPattern("MMM d");
dates = new ArrayList<>();
int numDays = 14;
LocalDate today = LocalDate.now();
minimumDate = today.minusDays(numDays);
LocalDate currentDay = minimumDate;
dateMap = new HashMap<>();
for (int i = 0; i < numDays + 1; i++) {
float index = (float) i;
String dateString = currentDay.format(formatter);
dates.add(dateString);
dateMap.put(dateString, i);
BarEntry barEntry = new BarEntry(index, new float[] { 0, 0, 0, 0 });
entries.add(barEntry);
currentDay = currentDay.plusDays(1);
}
xAxis.setValueFormatter(new MyXAxisValueFormatter(dates));
xAxis.setLabelCount(numDays);
xAxis.setGranularity(1f);
xAxis.setLabelRotationAngle(45f);
UserAccount currentUser = HabitUpApplication.getCurrentUser();
// Get user events
ArrayList<HabitEvent> eventList = currentUser.getEventList().getEvents();
for (HabitEvent event : eventList) {
if (withinDateRange(event.getCompletedate(), minimumDate)) {
addChartEntry(event);
}
}
set = new BarDataSet(entries, "");
int red = Color.parseColor(Attributes.getColour("Physical"));
int purple = Color.parseColor(Attributes.getColour("Mental"));
int green = Color.parseColor(Attributes.getColour("Discipline"));
int blue = Color.parseColor(Attributes.getColour("Social"));
int[] colors = {red, purple, green, blue};
set.setColors(colors);
set.setStackLabels(new String[]{"Physical", "Mental", "Discipline", "Social"});
set.setDrawValues(false);
BarData data = new BarData(set);
data.setBarWidth(0.6f);
YAxis leftAxis = chart.getAxisLeft();
leftAxis.setValueFormatter(new MyYAxisValueFormatter());
leftAxis.setGranularity(1f);
leftAxis.setAxisMinimum(0f);
chart.getAxisRight().setEnabled(false);
chart.setData(data);
chart.setFitBars(true);
chart.getXAxis().setDrawGridLines(false);
chart.getAxisLeft().setDrawGridLines(false);
chart.getDescription().setEnabled(false);
animateChart();
chart.invalidate();
return view;
}
示例12: nowDay
import java.time.LocalDate; //导入方法依赖的package包/类
public static String nowDay(String formatter) {
LocalDate localDate = LocalDate.now(ZoneId.systemDefault());
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(formatter);
return localDate.format(dateTimeFormatter);
}
示例13: parse
import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public String parse(final LocalDate jsonParsed) {
return jsonParsed.format(FormatConfig.DATE_FORMAT);
}
示例14: Milestone
import java.time.LocalDate; //导入方法依赖的package包/类
public Milestone(String name, String details, LocalDate deadline)
{
super(name, details);
this.deadline = new Deadline(deadline.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + "T00:00:01Z");
}
示例15: conveterDataPadraoBr
import java.time.LocalDate; //导入方法依赖的package包/类
/**
* Tratamento de datas para o padr�o brasileiro
*
* @param localDate Data � ser tratada
*
* @return Data tratada
*/
public static String conveterDataPadraoBr(LocalDate localDate) {
return localDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy"));
}