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

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

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

Helper.timeFromHourMinuteSecond介绍

[英]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.
[中]用小时、分钟、秒来回答时间。这就避免了不推荐使用、效率低下和并发瓶颈的日期构造函数。小时、分钟、秒是日历使用的值,即年从0开始,月从0到11,日期从1到31。

代码示例

代码示例来源: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: 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/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: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * Answer a Time from a string representation.
 * This method will accept times in the following
 * formats: HH-MM-SS, HH:MM:SS
 *
 * @param timeString - string representation of time
 * @return  - time representation of string
 */
public static java.sql.Time timeFromString(String timeString) throws ConversionException {
  int hour;
  int minute;
  int second;
  String timePortion = timeString;
  if (timeString.length() > 12) {
    // Longer strings are Timestamp format (ie. Sybase & Oracle)
    timePortion = timeString.substring(11, 19);
  }
  if ((timePortion.indexOf('-') == -1) && (timePortion.indexOf('/') == -1) && (timePortion.indexOf('.') == -1) && (timePortion.indexOf(':') == -1)) {
    throw ConversionException.incorrectTimeFormat(timePortion);
  }
  StringTokenizer timeStringTokenizer = new StringTokenizer(timePortion, " /:.-");
  try {
    hour = Integer.parseInt(timeStringTokenizer.nextToken());
    minute = Integer.parseInt(timeStringTokenizer.nextToken());
    second = Integer.parseInt(timeStringTokenizer.nextToken());
  } catch (NumberFormatException exception) {
    throw ConversionException.incorrectTimeFormat(timeString);
  }
  return timeFromHourMinuteSecond(hour, minute, second);
}

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

/**
 * Answer a Time from a string representation.
 * This method will accept times in the following
 * formats: HH-MM-SS, HH:MM:SS
 *
 * @param timeString - string representation of time
 * @return  - time representation of string
 */
public static java.sql.Time timeFromString(String timeString) throws ConversionException {
  int hour;
  int minute;
  int second;
  String timePortion = timeString;
  if (timeString.length() > 12) {
    // Longer strings are Timestamp format (ie. Sybase & Oracle)
    timePortion = timeString.substring(11, 19);
  }
  if ((timePortion.indexOf('-') == -1) && (timePortion.indexOf('/') == -1) && (timePortion.indexOf('.') == -1) && (timePortion.indexOf(':') == -1)) {
    throw ConversionException.incorrectTimeFormat(timePortion);
  }
  StringTokenizer timeStringTokenizer = new StringTokenizer(timePortion, " /:.-");
  try {
    hour = Integer.parseInt(timeStringTokenizer.nextToken());
    minute = Integer.parseInt(timeStringTokenizer.nextToken());
    second = Integer.parseInt(timeStringTokenizer.nextToken());
  } catch (NumberFormatException exception) {
    throw ConversionException.incorrectTimeFormat(timeString);
  }
  return timeFromHourMinuteSecond(hour, minute, second);
}

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

/**
 * Answer a Time from a string representation.
 * This method will accept times in the following
 * formats: HH-MM-SS, HH:MM:SS
 *
 * @param timeString - string representation of time
 * @return  - time representation of string
 */
public static java.sql.Time timeFromString(String timeString) throws ConversionException {
  int hour;
  int minute;
  int second;
  String timePortion = timeString;
  if (timeString.length() > 12) {
    // Longer strings are Timestamp format (ie. Sybase & Oracle)
    timePortion = timeString.substring(11, 19);
  }
  if ((timePortion.indexOf('-') == -1) && (timePortion.indexOf('/') == -1) && (timePortion.indexOf('.') == -1) && (timePortion.indexOf(':') == -1)) {
    throw ConversionException.incorrectTimeFormat(timePortion);
  }
  StringTokenizer timeStringTokenizer = new StringTokenizer(timePortion, " /:.-");
  try {
    hour = Integer.parseInt(timeStringTokenizer.nextToken());
    minute = Integer.parseInt(timeStringTokenizer.nextToken());
    second = Integer.parseInt(timeStringTokenizer.nextToken());
  } catch (NumberFormatException exception) {
    throw ConversionException.incorrectTimeFormat(timeString);
  }
  return timeFromHourMinuteSecond(hour, minute, second);
}

相关文章

Helper类方法