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();
}
java类org.joda.time.format.DateTimeParser的实例源码
TikaPoweredMetadataExtracter.java 文件源码
项目:alfresco-repository
阅读 20
收藏 0
点赞 0
评论 0
Tasks.java 文件源码
项目:heroic
阅读 26
收藏 0
点赞 0
评论 0
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");
}
Tasks.java 文件源码
项目:heroic
阅读 21
收藏 0
点赞 0
评论 0
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");
}
TikaPoweredMetadataExtracter.java 文件源码
项目:community-edition-old
阅读 30
收藏 0
点赞 0
评论 0
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();
}
Joda.java 文件源码
项目:elasticsearch_my
阅读 19
收藏 0
点赞 0
评论 0
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);
}
SimpleJodaTests.java 文件源码
项目:elasticsearch_my
阅读 32
收藏 0
点赞 0
评论 0
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");
}
DateUtility.java 文件源码
项目:QDrill
阅读 21
收藏 0
点赞 0
评论 0
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;
}
DateUtility.java 文件源码
项目:QDrill
阅读 21
收藏 0
点赞 0
评论 0
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;
}
CRMMessageFormatUtils.java 文件源码
项目:scribe
阅读 18
收藏 0
点赞 0
评论 0
/**
*
* @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;
}
DateUtility.java 文件源码
项目:drill
阅读 20
收藏 0
点赞 0
评论 0
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;
}
DateUtility.java 文件源码
项目:drill
阅读 19
收藏 0
点赞 0
评论 0
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;
}
StringToDateTimeConverter.java 文件源码
项目:GisGMP
阅读 25
收藏 0
点赞 0
评论 0
@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();
}
FormatterDateTimeRus.java 文件源码
项目:GisGMP
阅读 20
收藏 0
点赞 0
评论 0
@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();
}
FormatterDateTimeLocal.java 文件源码
项目:GisGMP
阅读 19
收藏 0
点赞 0
评论 0
@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();
}
JodaDateTimeAdapter.java 文件源码
项目:robin-java-sdk
阅读 21
收藏 0
点赞 0
评论 0
/**
* 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();
}
Contact.java 文件源码
项目:scoutmaster
阅读 27
收藏 0
点赞 0
评论 0
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()));
}
}
GGSQLTypeConverter.java 文件源码
项目:change-data-capture
阅读 20
收藏 0
点赞 0
评论 0
@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;
}
}
}
HL7DateTimeFormat.java 文件源码
项目:eHMP
阅读 19
收藏 0
点赞 0
评论 0
private static DateTimeParser twoDigitNumber(DateTimeFieldType fieldType) {
return new TwoDigitNumber(fieldType);
}
HL7DateTimeFormat.java 文件源码
项目:eHMP
阅读 23
收藏 0
点赞 0
评论 0
private static DateTimeParser dotMilliseconds() {
return new DateTimeFormatterBuilder().appendLiteral('.').appendMillisOfSecond(3).toParser();
}
HL7DateTimeFormat.java 文件源码
项目:eHMP
阅读 21
收藏 0
点赞 0
评论 0
private static DateTimeParser twoDigitNumber(DateTimeFieldType fieldType) {
return new TwoDigitNumber(fieldType);
}
HL7DateTimeFormat.java 文件源码
项目:eHMP
阅读 19
收藏 0
点赞 0
评论 0
private static DateTimeParser dotMilliseconds() {
return new DateTimeFormatterBuilder().appendLiteral('.').appendMillisOfSecond(3).toParser();
}
PointInTimeFormatter.java 文件源码
项目:eHMP
阅读 29
收藏 0
点赞 0
评论 0
/**
* 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);
}
PointInTimeFormatter.java 文件源码
项目:eHMP
阅读 18
收藏 0
点赞 0
评论 0
/**
* 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);
}