当前位置: 首页>>代码示例>>Java>>正文


Java DateTimeParser类代码示例

本文整理汇总了Java中org.joda.time.format.DateTimeParser的典型用法代码示例。如果您正苦于以下问题:Java DateTimeParser类的具体用法?Java DateTimeParser怎么用?Java DateTimeParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DateTimeParser类属于org.joda.time.format包,在下文中一共展示了DateTimeParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: TikaPoweredMetadataExtracter

import org.joda.time.format.DateTimeParser; //导入依赖的package包/类
public TikaPoweredMetadataExtracter(String extractorContext, HashSet<String> supportedMimeTypes, HashSet<String> supportedEmbedMimeTypes)
{
    super(supportedMimeTypes, supportedEmbedMimeTypes);

    this.extractorContext = extractorContext;

    // TODO Once TIKA-451 is fixed this list will get nicer
    DateTimeParser[] parsersUTC = {
        DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'").getParser(),
        DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZ").getParser()
    };
    DateTimeParser[] parsers = {
        DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss").getParser(),
        DateTimeFormat.forPattern("yyyy-MM-dd").getParser(),
        DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss").getParser(),
        DateTimeFormat.forPattern("yyyy/MM/dd").getParser(),
            DateTimeFormat.forPattern("EEE MMM dd hh:mm:ss zzz yyyy").getParser()
    };

    this.tikaUTCDateFormater = new DateTimeFormatterBuilder().append(null, parsersUTC).toFormatter().withZone(DateTimeZone.UTC);
    this.tikaDateFormater = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:TikaPoweredMetadataExtracter.java

示例2: parseTodayInstant

import org.joda.time.format.DateTimeParser; //导入依赖的package包/类
private static long parseTodayInstant(String input, final Chronology chrono, long now) {
    final DateTime n = new DateTime(now, chrono);

    for (final DateTimeParser p : today) {
        final DateTimeParserBucket bucket =
            new DateTimeParserBucket(0, chrono, null, null, 2000);

        bucket.saveField(chrono.year(), n.getYear());
        bucket.saveField(chrono.monthOfYear(), n.getMonthOfYear());
        bucket.saveField(chrono.dayOfYear(), n.getDayOfYear());

        try {
            p.parseInto(bucket, input, 0);
        } catch (IllegalArgumentException e) {
            // pass-through
            continue;
        }

        return bucket.computeMillis();
    }

    throw new IllegalArgumentException(input + " is not a valid instant");
}
 
开发者ID:spotify,项目名称:heroic,代码行数:24,代码来源:Tasks.java

示例3: parseFullInstant

import org.joda.time.format.DateTimeParser; //导入依赖的package包/类
private static long parseFullInstant(String input, final Chronology chrono) {
    for (final DateTimeParser p : full) {
        final DateTimeParserBucket bucket =
            new DateTimeParserBucket(0, chrono, null, null, 2000);

        try {
            p.parseInto(bucket, input, 0);
        } catch (IllegalArgumentException e) {
            // pass-through
            continue;
        }

        return bucket.computeMillis();
    }

    throw new IllegalArgumentException(input + " is not a valid instant");
}
 
开发者ID:spotify,项目名称:heroic,代码行数:18,代码来源:Tasks.java

示例4: getStrictStandardDateFormatter

import org.joda.time.format.DateTimeParser; //导入依赖的package包/类
public static FormatDateTimeFormatter getStrictStandardDateFormatter() {
    // 2014/10/10
    DateTimeFormatter shortFormatter = new DateTimeFormatterBuilder()
            .appendFixedDecimal(DateTimeFieldType.year(), 4)
            .appendLiteral('/')
            .appendFixedDecimal(DateTimeFieldType.monthOfYear(), 2)
            .appendLiteral('/')
            .appendFixedDecimal(DateTimeFieldType.dayOfMonth(), 2)
            .toFormatter()
            .withZoneUTC();

    // 2014/10/10 12:12:12
    DateTimeFormatter longFormatter = new DateTimeFormatterBuilder()
            .appendFixedDecimal(DateTimeFieldType.year(), 4)
            .appendLiteral('/')
            .appendFixedDecimal(DateTimeFieldType.monthOfYear(), 2)
            .appendLiteral('/')
            .appendFixedDecimal(DateTimeFieldType.dayOfMonth(), 2)
            .appendLiteral(' ')
            .appendFixedSignedDecimal(DateTimeFieldType.hourOfDay(), 2)
            .appendLiteral(':')
            .appendFixedSignedDecimal(DateTimeFieldType.minuteOfHour(), 2)
            .appendLiteral(':')
            .appendFixedSignedDecimal(DateTimeFieldType.secondOfMinute(), 2)
            .toFormatter()
            .withZoneUTC();

    DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder().append(longFormatter.withZone(DateTimeZone.UTC).getPrinter(), new DateTimeParser[]{longFormatter.getParser(), shortFormatter.getParser(), new EpochTimeParser(true)});

    return new FormatDateTimeFormatter("yyyy/MM/dd HH:mm:ss||yyyy/MM/dd||epoch_millis", builder.toFormatter().withZone(DateTimeZone.UTC), Locale.ROOT);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:Joda.java

示例5: testMultiParsers

import org.joda.time.format.DateTimeParser; //导入依赖的package包/类
public void testMultiParsers() {
    DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
    DateTimeParser[] parsers = new DateTimeParser[3];
    parsers[0] = DateTimeFormat.forPattern("MM/dd/yyyy").withZone(DateTimeZone.UTC).getParser();
    parsers[1] = DateTimeFormat.forPattern("MM-dd-yyyy").withZone(DateTimeZone.UTC).getParser();
    parsers[2] = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZone(DateTimeZone.UTC).getParser();
    builder.append(DateTimeFormat.forPattern("MM/dd/yyyy").withZone(DateTimeZone.UTC).getPrinter(), parsers);

    DateTimeFormatter formatter = builder.toFormatter();

    formatter.parseMillis("2009-11-15 14:12:12");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:SimpleJodaTests.java

示例6: getDateTimeFormatter

import org.joda.time.format.DateTimeParser; //导入依赖的package包/类
public static DateTimeFormatter getDateTimeFormatter() {

        if (dateTimeTZFormat == null) {
            DateTimeFormatter dateFormatter = DateTimeFormat.forPattern("yyyy-MM-dd");
            DateTimeParser optionalTime = DateTimeFormat.forPattern(" HH:mm:ss").getParser();
            DateTimeParser optionalSec = DateTimeFormat.forPattern(".SSS").getParser();
            DateTimeParser optionalZone = DateTimeFormat.forPattern(" ZZZ").getParser();

            dateTimeTZFormat = new DateTimeFormatterBuilder().append(dateFormatter).appendOptional(optionalTime).appendOptional(optionalSec).appendOptional(optionalZone).toFormatter();
        }

        return dateTimeTZFormat;
    }
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:14,代码来源:DateUtility.java

示例7: getTimeFormatter

import org.joda.time.format.DateTimeParser; //导入依赖的package包/类
public static DateTimeFormatter getTimeFormatter() {
    if (timeFormat == null) {
        DateTimeFormatter timeFormatter = DateTimeFormat.forPattern("HH:mm:ss");
        DateTimeParser optionalSec = DateTimeFormat.forPattern(".SSS").getParser();
        timeFormat = new DateTimeFormatterBuilder().append(timeFormatter).appendOptional(optionalSec).toFormatter();
    }
    return timeFormat;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:9,代码来源:DateUtility.java

示例8: validateInputDate

import org.joda.time.format.DateTimeParser; //导入依赖的package包/类
/**
 * 
 * @param finishDate
 * @return
 * @throws Exception
 */
public static final DateTime validateInputDate(final String date, final String permittedDateFormats) throws Exception {

  logger.debug("----Inside validateInputDate, date: " + date + " & permittedDateFormats: " + permittedDateFormats);

  /* Seperate all the formats */
  final String[] defaultDateFormats = permittedDateFormats.split(",");

  /* Create array for all date parsing formats */
  final DateTimeParser[] dateTimeParser = new DateTimeParser[defaultDateFormats.length];

  /* Parse with individual formats */
  for (int i = 0; i < defaultDateFormats.length; i++) {

    /* If format is valid */
    if (defaultDateFormats[i] != null && !"".equals(defaultDateFormats[i])) {

      /* Create new parser for each format */
      dateTimeParser[i] = DateTimeFormat.forPattern(defaultDateFormats[i].trim()).getParser();
    }
  }

  /* Final date formater builder */
  final DateTimeFormatter dateTimeFormatter = new DateTimeFormatterBuilder().append(null, dateTimeParser).toFormatter();

  /* Parse user supplied date */
  final DateTime updatedDate = dateTimeFormatter.parseDateTime(date);

  logger.debug("----Inside validateInputDate, updated date: " + updatedDate);

  /* Return updated date */
  return updatedDate;
}
 
开发者ID:inbravo,项目名称:scribe,代码行数:39,代码来源:CRMMessageFormatUtils.java

示例9: init

import org.joda.time.format.DateTimeParser; //导入依赖的package包/类
@PostConstruct
public void init() {
    DateTimeParser[] parsers = new DateTimeParser[patterns.length];
    for (int i = 0; i < patterns.length; i++) {
        parsers[i] = DateTimeFormat.forPattern(patterns[i]).getParser();
    }
    dateTimeFormatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
}
 
开发者ID:OlegNyr,项目名称:GisGMP,代码行数:9,代码来源:StringToDateTimeConverter.java

示例10: JodaDateTimeAdapter

import org.joda.time.format.DateTimeParser; //导入依赖的package包/类
/**
 * Build a JodaDateTimeAdapter
 *
 * @param parser Must be a DateTimeFormatter that is capable of parsing
 * @param printer Must be a DateTimeFormatter that is capable of printing
 */
public JodaDateTimeAdapter(DateTimeParser parser, DateTimePrinter printer) {
    if (null == parser || null == printer) {
        throw new IllegalArgumentException("Parser and printer may not be null");
    }

    this.parser = new DateTimeFormatterBuilder().append(parser).toFormatter();
    this.printer = new DateTimeFormatterBuilder().append(printer).toFormatter();
}
 
开发者ID:robinpowered,项目名称:robin-java-sdk,代码行数:15,代码来源:JodaDateTimeAdapter.java

示例11: setBirthDate

import org.joda.time.format.DateTimeParser; //导入依赖的package包/类
public void setBirthDate(final String fieldValue)
{
	final DateTimeParser[] parsers =
	{ DateTimeFormat.forPattern("yyyy-MM-dd").getParser(), DateTimeFormat.forPattern("yyyy/MM/dd").getParser() };
	final DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();

	if (fieldValue != null && fieldValue.length() > 0)
	{
		final DateTime date1 = formatter.parseDateTime(fieldValue);
		setBirthDate(new java.sql.Date(date1.toDate().getTime()));
	}
}
 
开发者ID:bsutton,项目名称:scoutmaster,代码行数:13,代码来源:Contact.java

示例12: getTimestamp

import org.joda.time.format.DateTimeParser; //导入依赖的package包/类
@Override
public Timestamp getTimestamp(DsColumn col, Calendar cal) throws SQLException{
	// How Oracle handles timestamps seems to be a mystery: http://stackoverflow.com/questions/14700962/default-jdbc-date-format-when-reading-date-as-a-string-from-resultset
	// What I have been able to figure out from GoldenGate doc...
	// 
	/*String val =  getStringInt(col);
	DateTimeFormatter sdf =  ISODateTimeFormat.dateTime();
	//DateTimeFormat.forPattern("YYYY-MM-DD:HH:MI.SS.FFFFFF"); // TimeStamp - for some reason the format is a bit differnt....
	DateTimeParser[] parsers = { 
	        DateTimeFormat.forPattern("YYYY-MM-DD:HH:MI.SS.FFFFFF" ).getParser(),// TimeStamp - for some reason the format is a bit differnt....
	        DateTimeFormat.forPattern( "yyyy-MM-dd" ).getParser() 
	        		};
	DateTimeFormatter formatter = new DateTimeFormatterBuilder().append( null, parsers ).toFormatter();

	return new Timestamp(sdf.parseDateTime(val).toDateTime(DateTimeZone.UTC).getMillis());*/
	
	
	/// NVM - just using oracle.sql types to parse everything
	
	// TODO: How do we know if there is a timezone? Maybe we can get it from getGGDataType/getGGDataSubType
	// Use TIMESTAMPTZ/TIMESTAMPLTZ  for time zones
	// GG specific behavior For TIMESTAMP WITH TIME ZONE, 3 options
	//   1) Default GG Extract aborts 
	//   2) INCLUDEREGIONID is set format is YYYY-MM-DD HH:MI.SS.FFFFFF in UTC
	//   3) INCLUDEREGIONIDWITHOFFSET is set  the format is YYYY-MM-DD HH:MI.SS.FFFFFF TZH:TZM (aka - time zone code is added) 
	String val =  getStringInt(col);
	// One would think that Oracle.sql.TIMESTAMP would be able to parse GG time stamps.... not that case :(
	// We try a bunch of ways to prase until one hopefully works.
	logger.debug("getTimestamp value {}", val);
	try {
		return new TIMESTAMP(val).timestampValue(cal);
	} catch (Exception e){
		logger.debug("getTimestamp try parsers");
		DateTimeParser[] parsers = { 
				DateTimeFormat.forPattern( "yyyy-MM-dd:HH:mm:ss.SSSSSS Z" ).getParser(),
		        DateTimeFormat.forPattern("yyyy-MM-dd:HH:mm:ss.SSSSSS" ).getParser(),// TimeStamp - for some reason the format is a bit different from the GG doc and JDBC standard
		        DateTimeFormat.forPattern("yyyy-MM-dd:HH:mm:ss" ).getParser()
		        		};
		DateTimeFormatter formatter = new DateTimeFormatterBuilder().append( null, parsers ).toFormatter();
		DateTime time = formatter.parseDateTime(val);
		logger.debug("time = {}", time);
		if (time != null){
		    return new Timestamp(time.toDateTime(DateTimeZone.forTimeZone(cal.getTimeZone())).getMillis());	
		}
		else{
			logger.warn("Timestamp value {} couldn't be parsed into a valid TimeStamp", val);
			return null;
		}
	}
	
}
 
开发者ID:rogers,项目名称:change-data-capture,代码行数:52,代码来源:GGSQLTypeConverter.java

示例13: twoDigitNumber

import org.joda.time.format.DateTimeParser; //导入依赖的package包/类
private static DateTimeParser twoDigitNumber(DateTimeFieldType fieldType) {
    return new TwoDigitNumber(fieldType);
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:4,代码来源:HL7DateTimeFormat.java

示例14: dotMilliseconds

import org.joda.time.format.DateTimeParser; //导入依赖的package包/类
private static DateTimeParser dotMilliseconds() {
    return new DateTimeFormatterBuilder().appendLiteral('.').appendMillisOfSecond(3).toParser();
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:4,代码来源:HL7DateTimeFormat.java

示例15: PointInTimeFormatter

import org.joda.time.format.DateTimeParser; //导入依赖的package包/类
/**
 * Creates a new formatter, however you will normally use the factory
 * or the builder.
 *
 * @param printer the internal printer, null if cannot print
 * @param parser  the internal parser, null if cannot parse
 */
public PointInTimeFormatter(DateTimePrinter printer, DateTimeParser parser) {
    super(printer, parser);
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:11,代码来源:PointInTimeFormatter.java


注:本文中的org.joda.time.format.DateTimeParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。