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


Java CachingDateFormat.getDateFormat方法代码示例

本文整理汇总了Java中org.alfresco.util.CachingDateFormat.getDateFormat方法的典型用法代码示例。如果您正苦于以下问题:Java CachingDateFormat.getDateFormat方法的具体用法?Java CachingDateFormat.getDateFormat怎么用?Java CachingDateFormat.getDateFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alfresco.util.CachingDateFormat的用法示例。


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

示例1: parseDate

import org.alfresco.util.CachingDateFormat; //导入方法依赖的package包/类
/**
 * Helper method to parse eaets from strings
 * @param stringDate String
 * @return Date
 */
private static Date parseDate(String stringDate)
{
   DateFormat df = CachingDateFormat.getDateFormat();
   df.setLenient(true);
   Date date;

   ParsePosition pp = new ParsePosition(0);
   date = df.parse(stringDate, pp);
   if ((pp.getIndex() < stringDate.length()) || (date == null))
   {
      date = new Date();
   }
   return date;

}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:21,代码来源:Duration.java

示例2: main

import org.alfresco.util.CachingDateFormat; //导入方法依赖的package包/类
public static void main(String[] args) throws ParseException, java.text.ParseException
{
    //Query query;

    Calendar start = Calendar.getInstance();
    Calendar end = Calendar.getInstance();
    SimpleDateFormat df = CachingDateFormat.getDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", false);

    Date date = df.parse("2011-09-31T00:00:00.000");
    System.out.println(date);
    start.setTime(date);
    System.out.println(start);

    date = df.parse("2011-10-28T00:00:00.000");
    System.out.println(date);
    end.setTime(date);
    System.out.println(end);


    LuceneQueryParser lqp = new LuceneQueryParser(null, null);
    Query query = lqp.buildDateTimeRange("WOOF", start, Calendar.DAY_OF_MONTH, end, Calendar.DAY_OF_MONTH, true, true);
    System.out.println("Query is " + query);
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:24,代码来源:AbstractLuceneQueryParser.java

示例3: test12EndOfDefaultFinancialQuarter

import org.alfresco.util.CachingDateFormat; //导入方法依赖的package包/类
/**
 * End of FQ
 * 
 * @throws ParseException
 */
public void test12EndOfDefaultFinancialQuarter() throws ParseException
{
    PeriodProvider provider = Period.getProvider(EndOfFinancialQuarter.PERIOD_TYPE);
    assertEquals(provider.getDefaultExpression(), "1");
    assertEquals(provider.getExpressionMutiplicity(), PeriodProvider.ExpressionMutiplicity.OPTIONAL);
    assertEquals(provider.getPeriodType(), EndOfFinancialQuarter.PERIOD_TYPE);
    assertEquals(DataTypeDefinition.INT, provider.getExpressionDataType());
    assertEquals("End Of Financial Quarter", provider.getDisplayLabel());
    
    AbstractEndOfCalendarPeriodProvider instance = (AbstractEndOfCalendarPeriodProvider) provider;
    instance.setStartDayOfMonth(1);
    instance.setStartMonth(Calendar.JANUARY);

    SimpleDateFormat df = CachingDateFormat.getDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", true);
    Period period = new Period(EndOfFinancialQuarter.PERIOD_TYPE);
    Date date;
    date = df.parse("2008-10-01T00:00:00.000");
    assertEquals("2008-12-31T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2008-12-31T23:59:59.998");
    assertEquals("2008-12-31T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2008-12-31T23:59:59.999");
    assertEquals("2009-03-31T23:59:59.999", df.format(period.getNextDate(date)));

    date = df.parse("2009-01-01T00:00:00.000");
    assertEquals("2009-03-31T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2009-03-31T23:59:59.998");
    assertEquals("2009-03-31T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2009-03-31T23:59:59.999");
    assertEquals("2009-06-30T23:59:59.999", df.format(period.getNextDate(date)));

    date = df.parse("2009-04-01T00:00:00.000");
    assertEquals("2009-06-30T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2009-06-30T23:59:59.998");
    assertEquals("2009-06-30T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2009-06-30T23:59:59.999");
    assertEquals("2009-09-30T23:59:59.999", df.format(period.getNextDate(date)));

    date = df.parse("2009-07-01T00:00:00.000");
    assertEquals("2009-09-30T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2009-09-30T23:59:59.998");
    assertEquals("2009-09-30T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2009-09-30T23:59:59.999");
    assertEquals("2009-12-31T23:59:59.999", df.format(period.getNextDate(date)));

    date = df.parse("2009-10-01T00:00:00.000");
    assertEquals("2009-12-31T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2009-12-31T23:59:59.998");
    assertEquals("2009-12-31T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2009-12-31T23:59:59.999");
    assertEquals("2010-03-31T23:59:59.999", df.format(period.getNextDate(date)));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:57,代码来源:PeriodTest.java

示例4: test14EndOfUKTaxQuarter

import org.alfresco.util.CachingDateFormat; //导入方法依赖的package包/类
/**
 * End of FQ
 * 
 * @throws ParseException
 */
public void test14EndOfUKTaxQuarter() throws ParseException
{
    PeriodProvider provider = Period.getProvider(EndOfFinancialQuarter.PERIOD_TYPE);
    assertEquals(provider.getDefaultExpression(), "1");
    assertEquals(provider.getExpressionMutiplicity(), PeriodProvider.ExpressionMutiplicity.OPTIONAL);
    assertEquals(provider.getPeriodType(), EndOfFinancialQuarter.PERIOD_TYPE);
    assertEquals(DataTypeDefinition.INT, provider.getExpressionDataType());

    AbstractEndOfCalendarPeriodProvider instance = (AbstractEndOfCalendarPeriodProvider) provider;
    instance.setStartDayOfMonth(6);
    instance.setStartMonth(Calendar.APRIL);
    
    SimpleDateFormat df = CachingDateFormat.getDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", true);
    Period period = new Period(EndOfFinancialQuarter.PERIOD_TYPE);
    Date date;
    date = df.parse("2008-04-06T00:00:00.000");
    assertEquals("2008-07-05T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2008-07-05T23:59:59.998");
    assertEquals("2008-07-05T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2008-07-05T23:59:59.999");
    assertEquals("2008-10-05T23:59:59.999", df.format(period.getNextDate(date)));

    date = df.parse("2008-07-06T00:00:00.000");
    assertEquals("2008-10-05T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2008-10-05T23:59:59.998");
    assertEquals("2008-10-05T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2008-10-05T23:59:59.999");
    assertEquals("2009-01-05T23:59:59.999", df.format(period.getNextDate(date)));

    date = df.parse("2008-10-06T00:00:00.000");
    assertEquals("2009-01-05T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2009-01-05T23:59:59.998");
    assertEquals("2009-01-05T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2009-01-05T23:59:59.999");
    assertEquals("2009-04-05T23:59:59.999", df.format(period.getNextDate(date)));

    date = df.parse("2009-01-06T00:00:00.000");
    assertEquals("2009-04-05T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2009-04-05T23:59:59.998");
    assertEquals("2009-04-05T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2009-04-05T23:59:59.999");
    assertEquals("2009-07-05T23:59:59.999", df.format(period.getNextDate(date)));

    date = df.parse("2009-04-06T00:00:00.000");
    assertEquals("2009-07-05T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2009-07-05T23:59:59.998");
    assertEquals("2009-07-05T23:59:59.999", df.format(period.getNextDate(date)));
    date = df.parse("2009-07-05T23:59:59.999");
    assertEquals("2009-10-05T23:59:59.999", df.format(period.getNextDate(date)));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:56,代码来源:PeriodTest.java


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