org.eclipse.persistence.internal.helper.Helper.releaseCalendar()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(135)

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

Helper.releaseCalendar介绍

[英]PERF: This is used to optimize Calendar conversion/printing. This should only be used when a calendar is temporarily required, when finished it must be released back.
[中]性能:用于优化日历转换/打印。仅当临时需要日历时才应使用此选项,完成后必须重新发布。

代码示例

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * Answer a Time with the hour, minute, second.
 * This builds a time avoiding the deprecated, inefficient and concurrency bottleneck date constructors.
 * The hour, minute, second are the values calendar uses,
 * i.e. year is from 0, month is 0-11, date is 1-31.
 */
public static java.sql.Time timeFromHourMinuteSecond(int hour, int minute, int second) {
  // Use a calendar to compute the correct millis for the date.
  Calendar localCalendar = allocateCalendar();
  localCalendar.clear();
  localCalendar.set(1970, 0, 1, hour, minute, second);
  long millis = localCalendar.getTimeInMillis();
  java.sql.Time time = new java.sql.Time(millis);
  releaseCalendar(localCalendar);
  return time;
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * Answer a Time with the hour, minute, second.
 * This builds a time avoiding the deprecated, inefficient and concurrency bottleneck date constructors.
 * The hour, minute, second are the values calendar uses,
 * i.e. year is from 0, month is 0-11, date is 1-31.
 */
public static java.sql.Time timeFromHourMinuteSecond(int hour, int minute, int second) {
  // Use a calendar to compute the correct millis for the date.
  Calendar localCalendar = allocateCalendar();
  localCalendar.clear();
  localCalendar.set(1970, 0, 1, hour, minute, second);
  long millis = localCalendar.getTimeInMillis();
  java.sql.Time time = new java.sql.Time(millis);
  releaseCalendar(localCalendar);
  return time;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * Answer a sql.Time from a Calendar.
 */
public static java.sql.Time timeFromCalendar(Calendar calendar) {
  if (!defaultTimeZone.equals(calendar.getTimeZone())) {
    // Must convert the calendar to the local timezone if different, as dates have no timezone (always local).
    Calendar localCalendar = allocateCalendar();
    localCalendar.setTimeInMillis(calendar.getTimeInMillis());
    java.sql.Time date = timeFromHourMinuteSecond(localCalendar.get(Calendar.HOUR_OF_DAY), localCalendar.get(Calendar.MINUTE), localCalendar.get(Calendar.SECOND));
    releaseCalendar(localCalendar);
    return date;
  }
  return timeFromHourMinuteSecond(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND));
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * Answer a sql.Time from a Calendar.
 */
public static java.sql.Time timeFromCalendar(Calendar calendar) {
  if (!defaultTimeZone.equals(calendar.getTimeZone())) {
    // Must convert the calendar to the local timezone if different, as dates have no timezone (always local).
    Calendar localCalendar = allocateCalendar();
    localCalendar.setTimeInMillis(calendar.getTimeInMillis());
    java.sql.Time date = timeFromHourMinuteSecond(localCalendar.get(Calendar.HOUR_OF_DAY), localCalendar.get(Calendar.MINUTE), localCalendar.get(Calendar.SECOND));
    releaseCalendar(localCalendar);
    return date;
  }
  return timeFromHourMinuteSecond(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND));
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * Answer a sql.Time from a Calendar.
 */
public static java.sql.Time timeFromCalendar(Calendar calendar) {
  if (!defaultTimeZone.equals(calendar.getTimeZone())) {
    // Must convert the calendar to the local timezone if different, as dates have no timezone (always local).
    Calendar localCalendar = allocateCalendar();
    localCalendar.setTimeInMillis(calendar.getTimeInMillis());
    java.sql.Time date = timeFromHourMinuteSecond(localCalendar.get(Calendar.HOUR_OF_DAY), localCalendar.get(Calendar.MINUTE), localCalendar.get(Calendar.SECOND));
    releaseCalendar(localCalendar);
    return date;
  }
  return timeFromHourMinuteSecond(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND));
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * Answer a sql.Date from a timestamp.
 */
public static java.sql.Date sqlDateFromUtilDate(java.util.Date utilDate) {
  // PERF: Avoid deprecated get methods, that are now very inefficient.
  Calendar calendar = allocateCalendar();
  calendar.setTime(utilDate);
  java.sql.Date date = dateFromCalendar(calendar);
  releaseCalendar(calendar);
  return date;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * Print the sql.Time.
 */
public static String printTime(java.sql.Time time) {
  // PERF: Avoid deprecated get methods, that are now very inefficient and used from toString.
  Calendar calendar = allocateCalendar();
  calendar.setTime(time);
  String string = printTime(calendar);
  releaseCalendar(calendar);
  return string;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * Print the sql.Timestamp without the nanos portion.
 */
public static String printTimestampWithoutNanos(java.sql.Timestamp timestamp) {
  // PERF: Avoid deprecated get methods, that are now very inefficient and used from toString.
  Calendar calendar = allocateCalendar();
  calendar.setTime(timestamp);
  String string = printCalendarWithoutNanos(calendar);
  releaseCalendar(calendar);
  return string;
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * Print the sql.Date.
 */
public static String printDate(java.sql.Date date) {
  // PERF: Avoid deprecated get methods, that are now very inefficient and used from toString.
  Calendar calendar = allocateCalendar();
  calendar.setTime(date);
  String string = printDate(calendar);
  releaseCalendar(calendar);
  return string;
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * Print the sql.Time.
 */
public static String printTime(java.sql.Time time) {
  // PERF: Avoid deprecated get methods, that are now very inefficient and used from toString.
  Calendar calendar = allocateCalendar();
  calendar.setTime(time);
  String string = printTime(calendar);
  releaseCalendar(calendar);
  return string;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * Print the sql.Date.
 */
public static String printDate(java.sql.Date date) {
  // PERF: Avoid deprecated get methods, that are now very inefficient and used from toString.
  Calendar calendar = allocateCalendar();
  calendar.setTime(date);
  String string = printDate(calendar);
  releaseCalendar(calendar);
  return string;
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * Print the sql.Timestamp without the nanos portion.
 */
public static String printTimestampWithoutNanos(java.sql.Timestamp timestamp) {
  // PERF: Avoid deprecated get methods, that are now very inefficient and used from toString.
  Calendar calendar = allocateCalendar();
  calendar.setTime(timestamp);
  String string = printCalendarWithoutNanos(calendar);
  releaseCalendar(calendar);
  return string;
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * Answer a sql.Date from a timestamp.
 */
public static java.sql.Date sqlDateFromUtilDate(java.util.Date utilDate) {
  // PERF: Avoid deprecated get methods, that are now very inefficient.
  Calendar calendar = allocateCalendar();
  calendar.setTime(utilDate);
  java.sql.Date date = dateFromCalendar(calendar);
  releaseCalendar(calendar);
  return date;
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * Print the sql.Timestamp without the nanos portion.
 */
public static String printTimestampWithoutNanos(java.sql.Timestamp timestamp) {
  // PERF: Avoid deprecated get methods, that are now very inefficient and used from toString.
  Calendar calendar = allocateCalendar();
  calendar.setTime(timestamp);
  String string = printCalendarWithoutNanos(calendar);
  releaseCalendar(calendar);
  return string;
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * Answer a sql.Date from a timestamp.
 */
public static java.sql.Date sqlDateFromUtilDate(java.util.Date utilDate) {
  // PERF: Avoid deprecated get methods, that are now very inefficient.
  Calendar calendar = allocateCalendar();
  calendar.setTime(utilDate);
  java.sql.Date date = dateFromCalendar(calendar);
  releaseCalendar(calendar);
  return date;
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * Print the sql.Date.
 */
public static String printDate(java.sql.Date date) {
  // PERF: Avoid deprecated get methods, that are now very inefficient and used from toString.
  Calendar calendar = allocateCalendar();
  calendar.setTime(date);
  String string = printDate(calendar);
  releaseCalendar(calendar);
  return string;
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * Print the sql.Time.
 */
public static String printTime(java.sql.Time time) {
  // PERF: Avoid deprecated get methods, that are now very inefficient and used from toString.
  Calendar calendar = allocateCalendar();
  calendar.setTime(time);
  String string = printTime(calendar);
  releaseCalendar(calendar);
  return string;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * Answer a Time from a Date
 *
 * This implementation is based on the java.sql.Date class, not java.util.Date.
 * @param date - time representation of date
 * @return  - time representation of dateObject
 */
public static java.sql.Time timeFromDate(java.util.Date date) {
  // PERF: Avoid deprecated get methods, that are now very inefficient.
  Calendar calendar = allocateCalendar();
  calendar.setTime(date);
  java.sql.Time time = timeFromCalendar(calendar);
  releaseCalendar(calendar);
  return time;
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * Answer a Time from a Date
 *
 * This implementation is based on the java.sql.Date class, not java.util.Date.
 * @param timestampObject - time representation of date
 * @return  - time representation of dateObject
 */
public static java.sql.Time timeFromDate(java.util.Date date) {
  // PERF: Avoid deprecated get methods, that are now very inefficient.
  Calendar calendar = allocateCalendar();
  calendar.setTime(date);
  java.sql.Time time = timeFromCalendar(calendar);
  releaseCalendar(calendar);
  return time;
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * Answer a Time from a Date
 *
 * This implementation is based on the java.sql.Date class, not java.util.Date.
 * @param timestampObject - time representation of date
 * @return  - time representation of dateObject
 */
public static java.sql.Time timeFromDate(java.util.Date date) {
  // PERF: Avoid deprecated get methods, that are now very inefficient.
  Calendar calendar = allocateCalendar();
  calendar.setTime(date);
  java.sql.Time time = timeFromCalendar(calendar);
  releaseCalendar(calendar);
  return time;
}

相关文章

Helper类方法