當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。