org.fujion.common.DateUtil.formatDate()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(172)

本文整理了Java中org.fujion.common.DateUtil.formatDate()方法的一些代码示例,展示了DateUtil.formatDate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateUtil.formatDate()方法的具体详情如下:
包路径:org.fujion.common.DateUtil
类名称:DateUtil
方法名:formatDate

DateUtil.formatDate介绍

[英]Converts a date/time value to a string, using the format dd-mmm-yyyy hh:mm. Because we cannot determine the absence of a time from a time of 24:00, we must assume a time of 24:00 means that no time is present and strip that from the return value.
[中]使用dd-mmm-yyy-hh:mm格式将日期/时间值转换为字符串。因为我们无法从24:00的时间中确定是否缺少时间,所以我们必须假设24:00的时间意味着不存在时间,并从返回值中删除该时间。

代码示例

代码示例来源:origin: org.fujion/fujion-common

/**
 * Converts a date/time value to a string, using the format dd-mmm-yyyy hh:mm. Because we cannot
 * determine the absence of a time from a time of 24:00, we must assume a time of 24:00 means
 * that no time is present and strip that from the return value.
 *
 * @param date Date value to convert.
 * @return Formatted string representation of the specified date, or an empty string if date is
 *         null.
 */
public static String formatDate(Date date) {
  return formatDate(date, false, false);
}

代码示例来源:origin: org.fujion/fujion-common

/**
 * Converts a date/time value to a string, using the format dd-mmm-yyyy hh:mm. Because we cannot
 * determine the absence of a time from a time of 24:00, we must assume a time of 24:00 means
 * that no time is present and strip that from the return value.
 *
 * @param date Date value to convert.
 * @param showTimezone If true, time zone information is also appended.
 * @return Formatted string representation of the specified date, or an empty string if date is
 *         null.
 */
public static String formatDate(Date date, boolean showTimezone) {
  return formatDate(date, showTimezone, false);
}

代码示例来源:origin: org.fujion/fujion-common

/**
 * Same as formatDate(Date, boolean) except replaces the time separator with the specified
 * string.
 *
 * @param date Date value to convert
 * @param timeSeparator String to use in place of default time separator
 * @return Formatted string representation of the specified date using the specified time
 *         separator.
 */
public static String formatDate(Date date, String timeSeparator) {
  return formatDate(date).replaceFirst(" ", timeSeparator);
}

代码示例来源:origin: org.fujion/fujion-common

/**
 * Create a date range from individual components.
 *
 * @param label Displayable text. If null, a default label is created.
 * @param startDate The start date.
 * @param endDate The end date.
 */
public DateRange(String label, Date startDate, Date endDate) {
  this.startDate = startDate;
  this.endDate = endDate;
  this.rawStartDate = DateUtil.formatDate(startDate);
  this.rawEndDate = DateUtil.formatDate(endDate);
  checkDates();
  this.label = label != null ? label : (rawStartDate + " to " + rawEndDate);
}

代码示例来源:origin: org.hspconsortium.carewebframework/cwf-ui-reporting

/**
 * Returns the current date in standard format.
 *
 * @return Timestamp for current date.
 */
public String getTimestamp() {
  return DateUtil.formatDate(DateUtil.stripTime(new Date()));
}

代码示例来源:origin: org.carewebframework/org.carewebframework.shell

@Override
protected String getValue() {
  return DateUtil.formatDate(editor.getValue());
}

代码示例来源:origin: org.hspconsortium.carewebframework/cwf-plugin-patientheader

private String formatDateAndAge(Date date) {
  return date == null ? null : DateUtil.formatDate(date) + " (" + DateUtil.formatAge(date) + ")";
}

代码示例来源:origin: org.hspconsortium.carewebframework/cwf-ui-reporting

/**
 * Add a row containing the specified header (left column) and value (right column).
 *
 * @param header Text for header column
 * @param value Date object
 */
protected void addRow(String header, Date value) {
  try {
    addRow(header, DateUtil.formatDate(value));
  } catch (Exception e) {
    log.error(e.getMessage(), e);
    addRow(header, e.getMessage());
  }
}

代码示例来源:origin: org.carewebframework/org.carewebframework.ui.core

/**
 * Sets the current date value.
 *
 * @param date The date value.
 */
public void setDate(Date date) {
  validateDate(date);
  setValue(DateUtil.formatDate(date));
}

代码示例来源:origin: org.carewebframework/org.carewebframework.plugin.chat

/**
 * Adds a message to the dialog panel.
 *
 * @param chatMessage Message to add.
 * @param self True if this user is the message author.
 */
private void addDialog(ChatMessage chatMessage, boolean self) {
  if (chatMessage != null) {
    String header = chatMessage.sender.getUserName() + " @ " + DateUtil.formatDate(chatMessage.timestamp);
    addDialog(header, chatMessage.message, self);
  }
}

代码示例来源:origin: org.carewebframework/org.carewebframework.ui.core

public String createLabelText(Object value, String prefix) {
  String text = StringUtils.trimToEmpty(value == null ? null
      : value instanceof Collection ? createLabelText((Collection<?>) value)
          : value instanceof Date ? DateUtil.formatDate((Date) value)
              : value instanceof String ? StrUtil.formatMessage((String) value) : value.toString());
  return text.isEmpty() ? "" : StrUtil.formatMessage(StringUtils.defaultString(prefix)) + text;
}

代码示例来源:origin: org.fujion/fujion-core

/**
 * Initialize the token consumer. A token consumer replaces its associated token with a computed
 * value and writes the result to the output stream.
 */
private void initTokenConsumers() {
  tokens.put("${schema-name}", (token, value) -> {
    for (String schema : schemas) {
      write(value.replace(token, schema));
    }
  });
  tokens.put("${schema-version}", (token, value) -> {
    write(value.replace(token, SchemaGenerator.formatVersion(version)));
  });
  tokens.put("${app-version}", (token, value) -> {
    write(value.replace(token, version));
  });
  tokens.put("${generated-on}", (token, value) -> {
    write(value.replace(token, DateUtil.formatDate(new Date())));
  });
}

代码示例来源:origin: org.fujion/fujion-common

private void doTestFormatting(String time, String expected) throws Exception {
  SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy" + (time.length() == 0 ? "" : " HH:mm"));
  Date date = formatter.parse(DATE + time);
  assertEquals(DateUtil.formatDate(date), DATE + expected);
}

代码示例来源:origin: org.hspconsortium.carewebframework/cwf-ui-patientselection-core

/**
 * Adds a demographic element to the demographic panel.
 *
 * @param root Root component.
 * @param labelId The id of the label to use.
 * @param object The element to be added.
 * @param style CSS styling to apply to element (may be null).
 */
protected void addDemographic(BaseUIComponent root, String labelId, Object object, String style) {
  object = object instanceof PrimitiveType ? ((PrimitiveType<?>) object).getValue() : object;
  String value = object == null ? null
      : object instanceof Date ? DateUtil.formatDate((Date) object) : object.toString().trim();
  if (!StringUtils.isEmpty(value)) {
    Label lbl = new Label((labelId == null ? "" : getDemographicLabel(labelId) + ": ") + value);
    root.addChild(lbl);
    if (style != null) {
      lbl.addStyles(style);
    }
  }
}

代码示例来源:origin: org.fujion/fujion-common

private void testDate(Date date, boolean showTimezone, boolean ignoreTime) {
  String text = DateUtil.formatDate(date, showTimezone, ignoreTime);
  print(text);
  Date date2 = DateUtil.parseDate(text);
  String text2 = DateUtil.formatDate(date2, showTimezone, ignoreTime);
  assertEquals(text, text2);
}

代码示例来源:origin: org.fujion/fujion-common

private void testDateFormat(String tz, String time) throws Exception {
  SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy HH:mm zzz");
  Date date = formatter.parse(DATE + " 13:04 EST"); // Reference date/time is 21-Nov-1978 13:04 EST
  TimeZone.setDefault(TimeZone.getTimeZone(tz));
  String DATE_TIME_NOTZ = DATE + " " + time;
  String DATE_TIME_TZ = DATE_TIME_NOTZ + " " + tz;
  assertEquals(DATE_TIME_TZ, DateUtil.formatDate(date, true));
  assertEquals(DATE_TIME_NOTZ, DateUtil.formatDate(date));
  assertEquals(DATE, DateUtil.formatDate(date, true, true));
  assertEquals(DATE_TIME_NOTZ, DateUtil.formatDate(date, false));
  assertEquals(DATE_TIME_NOTZ, DateUtil.formatDate(date, false, false));
  
  formatter = new SimpleDateFormat("dd-MMM-yyyy");
  date = formatter.parse(DATE);
  assertEquals(DATE, DateUtil.formatDate(date, true));
  assertEquals(DATE, DateUtil.formatDate(date));
  assertEquals(DATE, DateUtil.formatDate(date, true, true));
  assertEquals(DATE, DateUtil.formatDate(date, false));
  assertEquals(DATE, DateUtil.formatDate(date, false, false));
}

代码示例来源:origin: org.hspconsortium.carewebframework/cwf-ui-reporting

/**
 * Retrieves a formatted header for the current patient.
 *
 * @return Formatted header.
 */
public String getPatientInfo() {
  Patient patient = PatientContext.getActivePatient();
  String text;
  if (patient == null) {
    text = "No Patient Selected";
  } else {
    Identifier mrn = FhirUtil.getMRN(patient); // May be null!
    text = FhirUtil.formatName(patient.getName());
    if (mrn != null) {
      text += "  #" + mrn.getValue();
    }
    String gender = patient.hasGender() ? patient.getGender().getDisplay() : "";
    if (!StringUtils.isEmpty(gender)) {
      text += "   (" + gender + ")";
    }
    Date deceased = patient.getDeceased() instanceof DateType ? ((DateType) patient.getDeceased()).getValue() : null;
    String age = DateUtil.formatAge(patient.getBirthDate(), true, deceased);
    text += "  Age: " + age;
    if (deceased != null) {
      text += "  Died: " + DateUtil.formatDate(deceased);
    }
  }
  return text;
}

代码示例来源:origin: org.hspconsortium.carewebframework/cwf-ui-patientselection-core

info = dob == null ? "" : DateUtil.formatDate(dob);

相关文章