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


Java DateTimeFormatterBuilder类代码示例

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


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

示例1: TikaPoweredMetadataExtracter

import org.joda.time.format.DateTimeFormatterBuilder; //导入依赖的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: dateTime

import org.joda.time.format.DateTimeFormatterBuilder; //导入依赖的package包/类
public static DateTimeFormatter dateTime() {
    if (hl7 == null) {
        hl7 = new DateTimeFormatterBuilder()
                .appendYear(4, 4)
                .appendMonthOfYear(2)
                .appendDayOfMonth(2)
                .appendHourOfDay(2)
                .appendMinuteOfHour(2)
                .appendSecondOfMinute(2)
                .appendLiteral('.')
                .appendMillisOfSecond(3)
                .appendTimeZoneOffset(null, false, 2, 2)
                .toFormatter();
    }
    return hl7;
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:17,代码来源:HL7DateTimeFormat.java

示例3: TimeConverter

import org.joda.time.format.DateTimeFormatterBuilder; //导入依赖的package包/类
/**
 * creates instance with specific rounding.
 *
 * @param rounding
 *            rounding
 */
public TimeConverter(Rounding rounding) {
    this.rounding = rounding;
    char separator = DecimalFormatSymbols.getInstance().getDecimalSeparator();
    DateTimeFormatterBuilder parseBuilder = new DateTimeFormatterBuilder().appendHourOfDay(2).appendLiteral(':')
            .appendMinuteOfHour(2);
    parseBuilder.appendOptional(new DateTimeFormatterBuilder().appendLiteral(separator)
            .appendFractionOfMinute(0, 1).toParser());
    this.parse = parseBuilder.toFormatter();
    DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder().appendHourOfDay(1).appendLiteral(':')
            .appendMinuteOfHour(2);
    DateTimeFormatterBuilder builderFull = new DateTimeFormatterBuilder().appendHourOfDay(2).appendLiteral(':')
            .appendMinuteOfHour(2);
    if (rounding != Rounding.MINUTE) {
        builder.appendLiteral(separator).appendFractionOfMinute(1, 1);
        builderFull.appendLiteral(separator).appendFractionOfMinute(1, 1);
    }
    this.print = builder.toFormatter();
    this.printFull = builderFull.toFormatter();
    this.duration = new DecimalFormat("###.#");
    this.printXml = ISODateTimeFormat.hourMinuteSecond();
}
 
开发者ID:jub77,项目名称:grafikon,代码行数:28,代码来源:TimeConverter.java

示例4: onCreate

import org.joda.time.format.DateTimeFormatterBuilder; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Crashlytics.start(this);
    EventBus.getDefault().register(this);
    connection = getConnection();
    setContentView(R.layout.activity_main);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    ButterKnife.inject(this, this);
    DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
    formatter = builder.appendHourOfDay(2).appendLiteral(':')
            .appendMinuteOfHour(2).appendLiteral(':')
            .appendSecondOfMinute(2).toFormatter();

    textView.setMovementMethod(new ScrollingMovementMethod());
    textView.setTypeface(Typeface.MONOSPACE);

    if (savedInstanceState == null) {
        Intent intent = new Intent(this, BackServiceImpl.class);
        startService(intent);
    } else {
        String logText = savedInstanceState.getString(LOG_EXTRA);
        textView.setText(logText);
    }
}
 
开发者ID:corneliudascalu,项目名称:google-glass-share-barcode-bluetooth,代码行数:26,代码来源:MainActivity.java

示例5: initialValue

import org.joda.time.format.DateTimeFormatterBuilder; //导入依赖的package包/类
@Override
protected DateTimeFormatter initialValue() {
	return new DateTimeFormatterBuilder()
		.append(DateTimeFormat.forPattern("yyyy-MM-dd"))                                            
		.appendOptional(
				new DateTimeFormatterBuilder()
					.appendLiteral('T')
					.appendOptional(
							new DateTimeFormatterBuilder()
								.append(DateTimeFormat.forPattern("HH"))
								.appendOptional(
										new DateTimeFormatterBuilder()
											.append(DateTimeFormat.forPattern(":mm"))
												.appendOptional(
														new DateTimeFormatterBuilder()
															.append(DateTimeFormat.forPattern(":ss"))
														.toParser())
										.toParser())
							.toParser())
				.toParser())
		.toFormatter();
}
 
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:23,代码来源:FieldInjectorRegistry.java

示例6: onCreate

import org.joda.time.format.DateTimeFormatterBuilder; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (getArguments() != null) {
        setData(getArguments());
    }

    DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
    mFormatter = builder
            .appendYear(4, 4).appendLiteral("-")
            .appendMonthOfYear(2).appendLiteral("-")
            .appendDayOfMonth(2).appendLiteral(" at ")
            .appendHourOfDay(2).appendLiteral(":")
            .appendMinuteOfHour(2)
            .toFormatter();
}
 
开发者ID:corneliudascalu,项目名称:mvp-notes,代码行数:18,代码来源:NoteDetailsDialogFragment.java

示例7: buildDTFormatter

import org.joda.time.format.DateTimeFormatterBuilder; //导入依赖的package包/类
/**
 * 
 * @return a formatter for common ISO strings
 */
private DateTimeFormatter buildDTFormatter() {
	//build a parser for time stamps
	return new DateTimeFormatterBuilder()
		.appendYear(4, 4)		//4 digit year (YYYY)
		.appendLiteral("-")
		.appendMonthOfYear(2)	//2 digit month (MM)
		.appendLiteral("-")
		.appendDayOfMonth(2)	//2 digit day (DD)
		.appendLiteral("T")
		.appendHourOfDay(2)		//2 digit hour (hh)
		.appendLiteral(":")
		.appendMinuteOfHour(2)	//2 digit minute (mm)
		.appendLiteral(":")
		.appendSecondOfMinute(2)//2 digit second (ss)
		//optional 3 digit milliseconds of second
		.appendOptional(new DateTimeFormatterBuilder()
							.appendLiteral(".")
							.appendMillisOfSecond(3)
							.toParser())
		//optional time zone offset as (+|-)hh:mm
		.appendOptional(new DateTimeFormatterBuilder()
							.appendTimeZoneOffset("", true, 2, 2)
							.toParser())
		.toFormatter();
}
 
开发者ID:52North,项目名称:SES,代码行数:30,代码来源:ObjectPropertyValueParser.java

示例8: buildDTFormatter

import org.joda.time.format.DateTimeFormatterBuilder; //导入依赖的package包/类
/**
 * 
 * @return a formatter for common ISO strings
 */
private DateTimeFormatter buildDTFormatter() {
	//build a parser for time stamps
	return new DateTimeFormatterBuilder()
	.appendYear(4, 4)		//4 digit year (YYYY)
	.appendLiteral("-")
	.appendMonthOfYear(2)	//2 digit month (MM)
	.appendLiteral("-")
	.appendDayOfMonth(2)	//2 digit day (DD)
	.appendLiteral("T")
	.appendHourOfDay(2)		//2 digit hour (hh)
	.appendLiteral(":")
	.appendMinuteOfHour(2)	//2 digit minute (mm)
	.appendLiteral(":")
	.appendSecondOfMinute(2)//2 digit second (ss)
	//optional 3 digit milliseconds of second
	.appendOptional(new DateTimeFormatterBuilder()
	.appendLiteral(".")
	.appendMillisOfSecond(3)
	.toParser())
	//optional time zone offset as (+|-)hh:mm
	.appendOptional(new DateTimeFormatterBuilder()
	.appendTimeZoneOffset("", true, 2, 2)
	.toParser())
	.toFormatter();
}
 
开发者ID:52North,项目名称:SES,代码行数:30,代码来源:OWS8Parser.java

示例9: toUIString

import org.joda.time.format.DateTimeFormatterBuilder; //导入依赖的package包/类
public String toUIString()
{
       DateTimeFormatter DF = new DateTimeFormatterBuilder()
       .appendYear(4, 4)
       .appendLiteral('-')                
       .appendMonthOfYear(1)
       .appendLiteral('-')                
       .appendDayOfMonth(1)
       .appendLiteral(" ")
       .appendHourOfDay(2)
       .appendLiteral(':')                
       .appendMinuteOfHour(2)
       .appendLiteral(':')
       .appendSecondOfMinute(2)
       .appendLiteral('.')
       .appendMillisOfSecond(1)
       .toFormatter();

       return DF.print( toDateTime());
}
 
开发者ID:toby1984,项目名称:threadwatch,代码行数:21,代码来源:HiResTimestamp.java

示例10: toUIString

import org.joda.time.format.DateTimeFormatterBuilder; //导入依赖的package包/类
public String toUIString()
{
       DateTimeFormatter DF = new DateTimeFormatterBuilder()
       .appendYear(4, 4)
       .appendLiteral('-')                
       .appendMonthOfYear(1)
       .appendLiteral('-')                
       .appendDayOfMonth(1)
       .appendLiteral(" ")
       .appendHourOfDay(2)
       .appendLiteral(':')                
       .appendMinuteOfHour(2)
       .appendLiteral(':')
       .appendSecondOfMinute(2)
       .appendLiteral('.')
       .appendMillisOfSecond(1)
       .toFormatter();

       final String start = DF.print( this.start.toDateTime());
       final String end = DF.print( this.end.toDateTime());
       return start+" - "+end+" [ "+getDurationInMilliseconds()+" ms ]";
}
 
开发者ID:toby1984,项目名称:threadwatch,代码行数:23,代码来源:HiResInterval.java

示例11: getStrictStandardDateFormatter

import org.joda.time.format.DateTimeFormatterBuilder; //导入依赖的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

示例12: testMultiParsers

import org.joda.time.format.DateTimeFormatterBuilder; //导入依赖的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

示例13: getDateTimeFormatter

import org.joda.time.format.DateTimeFormatterBuilder; //导入依赖的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

示例14: getTimeFormatter

import org.joda.time.format.DateTimeFormatterBuilder; //导入依赖的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

示例15: validateInputDate

import org.joda.time.format.DateTimeFormatterBuilder; //导入依赖的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


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