當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。