org.joda.time.format.DateTimeFormatter.parseLocalTime()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(199)

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

DateTimeFormatter.parseLocalTime介绍

[英]Parses only the local time from the given text, returning a new LocalDate.

This will parse the text fully according to the formatter, using the UTC zone. Once parsed, only the local time will be used. This means that any parsed date, time-zone or offset field is completely ignored. It also means that the zone and offset-parsed settings are ignored.
[中]只解析给定文本中的本地时间,返回新的LocalDate。
这将使用UTC区域完全根据格式化程序解析文本。解析后,将只使用本地时间。这意味着任何解析的日期、时区或偏移量字段都将被完全忽略。这还意味着忽略区域和偏移量解析设置。

代码示例

代码示例来源:origin: joda-time/joda-time

/**
 * Parses a {@code LocalTime} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static LocalTime parse(String str, DateTimeFormatter formatter) {
  return formatter.parseLocalTime(str);
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Parses a {@code LocalTime} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static LocalTime parse(String str, DateTimeFormatter formatter) {
  return formatter.parseLocalTime(str);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public LocalTime parse(String text, Locale locale) throws ParseException {
  return JodaTimeContextHolder.getFormatter(this.formatter, locale).parseLocalTime(text);
}

代码示例来源:origin: org.springframework/spring-context

@Override
public LocalTime parse(String text, Locale locale) throws ParseException {
  return JodaTimeContextHolder.getFormatter(this.formatter, locale).parseLocalTime(text);
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Parses a {@code LocalTime} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static LocalTime parse(String str, DateTimeFormatter formatter) {
  return formatter.parseLocalTime(str);
}

代码示例来源:origin: com.fasterxml.jackson.datatype/jackson-datatype-joda

@Override
  protected LocalTime deserialize(String key, DeserializationContext ctxt) throws IOException {
    return parser.parseLocalTime(key);
  }
}

代码示例来源:origin: stackoverflow.com

import org.joda.time.*;
import org.joda.time.format.*;

public class Test {
  public static void main(String[] args) {
    DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
    LocalTime time = formatter.parseLocalTime("14:10");
    time = time.plusMinutes(10);
    System.out.println(formatter.print(time));
  }       
}

代码示例来源:origin: stackoverflow.com

return TIME_FORMAT.parseLocalTime(dateAsString);

代码示例来源:origin: com.fasterxml.jackson.datatype/jackson-datatype-joda

String str = p.getText().trim();
  return (str.length() == 0) ? null
      : _format.createParser(ctxt).parseLocalTime(str);
default:

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Parses a {@code LocalTime} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static LocalTime parse(String str, DateTimeFormatter formatter) {
  return formatter.parseLocalTime(str);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Parses a {@code LocalTime} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static LocalTime parse(String str, DateTimeFormatter formatter) {
  return formatter.parseLocalTime(str);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/**
 * Parses a {@code LocalTime} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static LocalTime parse(String str, DateTimeFormatter formatter) {
  return formatter.parseLocalTime(str);
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Parses a {@code LocalTime} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static LocalTime parse(String str, DateTimeFormatter formatter) {
  return formatter.parseLocalTime(str);
}

代码示例来源:origin: actframework/actframework

@Override
protected LocalTime parse(DateTimeFormatter formatter, String value) {
  if (formatter == super.formatter) {
    // in the default case we might want to patch the value
    String amended = (isIso && !value.endsWith("Z")) ? value + "Z" : value;
    return formatter.parseLocalTime(amended);
  }
  return formatter.parseLocalTime(value);
}

代码示例来源:origin: org.actframework/act

@Override
protected LocalTime parse(DateTimeFormatter formatter, String value) {
  if (formatter == super.formatter) {
    // in the default case we might want to patch the value
    String amended = (isIso && !value.endsWith("Z")) ? value + "Z" : value;
    return formatter.parseLocalTime(amended);
  }
  return formatter.parseLocalTime(value);
}

代码示例来源:origin: stackoverflow.com

String actual = "18:01:23";
String limit = "00:16:23";

DateTimeFormatter df = DateTimeFormat.forPattern("HH:mm:ss");

DateTime ac = df.parseLocalTime(actual).toDateTimeToday();
DateTime lim = df.parseLocalTime(limit).toDateTimeToday().plusDays(1);

if (ac.isBefore(lim)) {
  System.out.println("Not yet at the limit");
}

代码示例来源:origin: stackoverflow.com

// © 2013 Basil Bourque. This source code may be used freely forever by anyone taking full responsibility for doing so.
// import org.joda.time.*;
// import org.joda.time.format.*;

String timeString_24Hour = "14:35:22";

// From String to LocalTime object
DateTimeFormatter formatter_24HourTime = DateTimeFormat.forPattern("HH:mm:ss");
LocalTime localTime = formatter_24HourTime.parseLocalTime( timeString_24Hour );

// From LocalTime object to String
DateTimeFormatter formatter_12HourTime = DateTimeFormat.forPattern("h:mm:ss aa");
String timeString_12Hour = formatter_12HourTime.print( localTime );

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
  public LocalTime convert(CharSequence in, Context context) throws Exception {
    if (in == null || in.length() == 0) return null;
    return dateTimeFormatter.parseLocalTime(String.valueOf(in));
  }
}

代码示例来源:origin: net.s-jr.utils.converterutils/joda-converter-utils

@Contract("null -> null")
  public static @Nullable LocalTime stringToJodaTime(final @Nullable String s) {
    if (StringUtils.isBlank(s)) {
      return null;
    }
    return HHmm.parseLocalTime(s);
  }
}

代码示例来源:origin: org.kuali.kpme/kpme-tk-lm-impl

public void setActionTime(String actionTime) {
  if (StringUtils.isNotBlank(actionTime)) {
    setLocalTime(actionTime != null ? FORMATTER.parseLocalTime(actionTime) : null);
    if (localDate != null
        && localTime != null) {
      actionDateTime = localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate();
    }
  }
}

相关文章