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

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

本文整理了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

  1. /**
  2. * Answer a sql.Time from a Calendar.
  3. */
  4. public static java.sql.Time timeFromCalendar(Calendar calendar) {
  5. if (!defaultTimeZone.equals(calendar.getTimeZone())) {
  6. // Must convert the calendar to the local timezone if different, as dates have no timezone (always local).
  7. Calendar localCalendar = allocateCalendar();
  8. localCalendar.setTimeInMillis(calendar.getTimeInMillis());
  9. java.sql.Time date = timeFromHourMinuteSecond(localCalendar.get(Calendar.HOUR_OF_DAY), localCalendar.get(Calendar.MINUTE), localCalendar.get(Calendar.SECOND));
  10. releaseCalendar(localCalendar);
  11. return date;
  12. }
  13. return timeFromHourMinuteSecond(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND));
  14. }

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

  1. /**
  2. * Answer a sql.Time from a Calendar.
  3. */
  4. public static java.sql.Time timeFromCalendar(Calendar calendar) {
  5. if (!defaultTimeZone.equals(calendar.getTimeZone())) {
  6. // Must convert the calendar to the local timezone if different, as dates have no timezone (always local).
  7. Calendar localCalendar = allocateCalendar();
  8. localCalendar.setTimeInMillis(calendar.getTimeInMillis());
  9. java.sql.Time date = timeFromHourMinuteSecond(localCalendar.get(Calendar.HOUR_OF_DAY), localCalendar.get(Calendar.MINUTE), localCalendar.get(Calendar.SECOND));
  10. releaseCalendar(localCalendar);
  11. return date;
  12. }
  13. return timeFromHourMinuteSecond(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND));
  14. }

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

  1. /**
  2. * Answer a sql.Time from a Calendar.
  3. */
  4. public static java.sql.Time timeFromCalendar(Calendar calendar) {
  5. if (!defaultTimeZone.equals(calendar.getTimeZone())) {
  6. // Must convert the calendar to the local timezone if different, as dates have no timezone (always local).
  7. Calendar localCalendar = allocateCalendar();
  8. localCalendar.setTimeInMillis(calendar.getTimeInMillis());
  9. java.sql.Time date = timeFromHourMinuteSecond(localCalendar.get(Calendar.HOUR_OF_DAY), localCalendar.get(Calendar.MINUTE), localCalendar.get(Calendar.SECOND));
  10. releaseCalendar(localCalendar);
  11. return date;
  12. }
  13. return timeFromHourMinuteSecond(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND));
  14. }

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

  1. /**
  2. * Answer a Time from a string representation.
  3. * This method will accept times in the following
  4. * formats: HH-MM-SS, HH:MM:SS
  5. *
  6. * @param timeString - string representation of time
  7. * @return - time representation of string
  8. */
  9. public static java.sql.Time timeFromString(String timeString) throws ConversionException {
  10. int hour;
  11. int minute;
  12. int second;
  13. String timePortion = timeString;
  14. if (timeString.length() > 12) {
  15. // Longer strings are Timestamp format (ie. Sybase & Oracle)
  16. timePortion = timeString.substring(11, 19);
  17. }
  18. if ((timePortion.indexOf('-') == -1) && (timePortion.indexOf('/') == -1) && (timePortion.indexOf('.') == -1) && (timePortion.indexOf(':') == -1)) {
  19. throw ConversionException.incorrectTimeFormat(timePortion);
  20. }
  21. StringTokenizer timeStringTokenizer = new StringTokenizer(timePortion, " /:.-");
  22. try {
  23. hour = Integer.parseInt(timeStringTokenizer.nextToken());
  24. minute = Integer.parseInt(timeStringTokenizer.nextToken());
  25. second = Integer.parseInt(timeStringTokenizer.nextToken());
  26. } catch (NumberFormatException exception) {
  27. throw ConversionException.incorrectTimeFormat(timeString);
  28. }
  29. return timeFromHourMinuteSecond(hour, minute, second);
  30. }

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

  1. /**
  2. * Answer a Time from a string representation.
  3. * This method will accept times in the following
  4. * formats: HH-MM-SS, HH:MM:SS
  5. *
  6. * @param timeString - string representation of time
  7. * @return - time representation of string
  8. */
  9. public static java.sql.Time timeFromString(String timeString) throws ConversionException {
  10. int hour;
  11. int minute;
  12. int second;
  13. String timePortion = timeString;
  14. if (timeString.length() > 12) {
  15. // Longer strings are Timestamp format (ie. Sybase & Oracle)
  16. timePortion = timeString.substring(11, 19);
  17. }
  18. if ((timePortion.indexOf('-') == -1) && (timePortion.indexOf('/') == -1) && (timePortion.indexOf('.') == -1) && (timePortion.indexOf(':') == -1)) {
  19. throw ConversionException.incorrectTimeFormat(timePortion);
  20. }
  21. StringTokenizer timeStringTokenizer = new StringTokenizer(timePortion, " /:.-");
  22. try {
  23. hour = Integer.parseInt(timeStringTokenizer.nextToken());
  24. minute = Integer.parseInt(timeStringTokenizer.nextToken());
  25. second = Integer.parseInt(timeStringTokenizer.nextToken());
  26. } catch (NumberFormatException exception) {
  27. throw ConversionException.incorrectTimeFormat(timeString);
  28. }
  29. return timeFromHourMinuteSecond(hour, minute, second);
  30. }

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

  1. /**
  2. * Answer a Time from a string representation.
  3. * This method will accept times in the following
  4. * formats: HH-MM-SS, HH:MM:SS
  5. *
  6. * @param timeString - string representation of time
  7. * @return - time representation of string
  8. */
  9. public static java.sql.Time timeFromString(String timeString) throws ConversionException {
  10. int hour;
  11. int minute;
  12. int second;
  13. String timePortion = timeString;
  14. if (timeString.length() > 12) {
  15. // Longer strings are Timestamp format (ie. Sybase & Oracle)
  16. timePortion = timeString.substring(11, 19);
  17. }
  18. if ((timePortion.indexOf('-') == -1) && (timePortion.indexOf('/') == -1) && (timePortion.indexOf('.') == -1) && (timePortion.indexOf(':') == -1)) {
  19. throw ConversionException.incorrectTimeFormat(timePortion);
  20. }
  21. StringTokenizer timeStringTokenizer = new StringTokenizer(timePortion, " /:.-");
  22. try {
  23. hour = Integer.parseInt(timeStringTokenizer.nextToken());
  24. minute = Integer.parseInt(timeStringTokenizer.nextToken());
  25. second = Integer.parseInt(timeStringTokenizer.nextToken());
  26. } catch (NumberFormatException exception) {
  27. throw ConversionException.incorrectTimeFormat(timeString);
  28. }
  29. return timeFromHourMinuteSecond(hour, minute, second);
  30. }

相关文章

Helper类方法