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


Java LocalDate.format方法代码示例

本文整理汇总了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;
}
 
开发者ID:jochen777,项目名称:jWebForm,代码行数:27,代码来源:TextDateType.java

示例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);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:11,代码来源:DatumFormatterUtil.java

示例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);
}
 
开发者ID:BBVA,项目名称:mirrorgate,代码行数:14,代码来源:ProgramIncrementServiceTest.java

示例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);
	}
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:16,代码来源:JsonWrapper.java

示例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);
}
 
开发者ID:Varoso,项目名称:JSK,代码行数:15,代码来源:JSKDateConverter.java

示例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);
}
 
开发者ID:Alienturnedhuman,项目名称:PearPlanner,代码行数:10,代码来源:Activity.java

示例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);
	}
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:13,代码来源:MethodUtils.java

示例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;
}
 
开发者ID:ivandavidov,项目名称:baud,代码行数:32,代码来源:Main.java

示例9: LocalDateToString

import java.time.LocalDate; //导入方法依赖的package包/类
private static String LocalDateToString(LocalDate value)
{
	return value.format(DateTimeFormatter.ofPattern("MM-dd"));
}
 
开发者ID:crazysnailboy,项目名称:Halloween,代码行数:5,代码来源:ModConfiguration.java

示例10: formatted

import java.time.LocalDate; //导入方法依赖的package包/类
private static String formatted(LocalDate date) {
    return date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
 
开发者ID:pivotal,项目名称:spring-samples,代码行数:4,代码来源:FeatureTest.java

示例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;
}
 
开发者ID:CMPUT301F17T29,项目名称:HabitUp,代码行数:82,代码来源:ChartFragment.java

示例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);
}
 
开发者ID:DreamYa0,项目名称:zeratul,代码行数:6,代码来源:DateUtils.java

示例13: parse

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public String parse(final LocalDate jsonParsed) {
  return jsonParsed.format(FormatConfig.DATE_FORMAT);
}
 
开发者ID:stefanstaniAIM,项目名称:IPPR2016,代码行数:5,代码来源:DbDateParser.java

示例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");
}
 
开发者ID:Alienturnedhuman,项目名称:PearPlanner,代码行数:6,代码来源:Milestone.java

示例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"));
}
 
开发者ID:pedrohnog,项目名称:Trabalhos-FIAP,代码行数:11,代码来源:DataUtil.java


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