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


Java CachingDateFormat类代码示例

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


CachingDateFormat类属于org.alfresco.util包,在下文中一共展示了CachingDateFormat类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getDateEnd

import org.alfresco.util.CachingDateFormat; //导入依赖的package包/类
/**
    * @param dateAndResolution
    * @return
 */
private String getDateEnd(Pair<Date, Integer> dateAndResolution)
{
	Calendar cal= Calendar.getInstance(I18NUtil.getLocale());
	cal.setTime(dateAndResolution.getFirst());
	switch(dateAndResolution.getSecond())
	{
	case Calendar.YEAR:
		cal.set(Calendar.MONTH, cal.getActualMaximum(Calendar.MONTH));
	case Calendar.MONTH:
		cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
	case Calendar.DAY_OF_MONTH:
		cal.set(Calendar.HOUR_OF_DAY, cal.getActualMaximum(Calendar.HOUR_OF_DAY));
	case Calendar.HOUR_OF_DAY:
		cal.set(Calendar.MINUTE, cal.getActualMaximum(Calendar.MINUTE));
	case Calendar.MINUTE:
		cal.set(Calendar.SECOND, cal.getActualMaximum(Calendar.SECOND));
	case Calendar.SECOND:
		cal.set(Calendar.MILLISECOND, cal.getActualMaximum(Calendar.MILLISECOND));
	case Calendar.MILLISECOND:
	default:
	}
	SimpleDateFormat formatter = CachingDateFormat.getSolrDatetimeFormat();
	formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
	return formatter.format(cal.getTime());
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:30,代码来源:Solr4QueryParser.java

示例3: getDateStart

import org.alfresco.util.CachingDateFormat; //导入依赖的package包/类
/**
    * @param dateAndResolution
    * @return
 */
private String getDateStart(Pair<Date, Integer> dateAndResolution)
{
	Calendar cal= Calendar.getInstance(I18NUtil.getLocale());
	cal.setTime(dateAndResolution.getFirst());
	switch(dateAndResolution.getSecond())
	{
	case Calendar.YEAR:
		cal.set(Calendar.MONTH, cal.getActualMinimum(Calendar.MONTH));
	case Calendar.MONTH:
		cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
	case Calendar.DAY_OF_MONTH:
		cal.set(Calendar.HOUR_OF_DAY, cal.getActualMinimum(Calendar.HOUR_OF_DAY));
	case Calendar.HOUR_OF_DAY:
		cal.set(Calendar.MINUTE, cal.getActualMinimum(Calendar.MINUTE));
	case Calendar.MINUTE:
		cal.set(Calendar.SECOND, cal.getActualMinimum(Calendar.SECOND));
	case Calendar.SECOND:
		cal.set(Calendar.MILLISECOND, cal.getActualMinimum(Calendar.MILLISECOND));
	case Calendar.MILLISECOND:
	default:
	}
	SimpleDateFormat formatter = CachingDateFormat.getSolrDatetimeFormat();
	formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
	return formatter.format(cal.getTime());
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:30,代码来源:Solr4QueryParser.java

示例4: 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

示例5: deserialiseDate

import org.alfresco.util.CachingDateFormat; //导入依赖的package包/类
/**
 * Convert XML date (of the form yyyy-MM-dd) to Date 
 * 
 * @param date  the xml representation of the date
 * @return  the date
 * @throws ParseException
 */
public static Date deserialiseDate(String date)
    throws ParseException
{
    Date xmlDate = null;
    if (date != null)
    {
        SimpleDateFormat df = CachingDateFormat.getDateOnlyFormat();
        xmlDate = df.parse(date);
    }
    return xmlDate;
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:19,代码来源:M2XML.java

示例6: serialiseDate

import org.alfresco.util.CachingDateFormat; //导入依赖的package包/类
/**
 * Convert date to XML date (of the form yyyy-MM-dd)
 * 
 * @param date  the date
 * @return  the xml representation of the date
 */
public static String serialiseDate(Date date)
{
    String xmlDate = null;
    if (date != null)
    {
        SimpleDateFormat df = CachingDateFormat.getDateOnlyFormat();
        xmlDate = df.format(date);
    }
    return xmlDate;
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:17,代码来源:M2XML.java

示例7: next

import org.alfresco.util.CachingDateFormat; //导入依赖的package包/类
public Token next() throws IOException
{
    SimpleDateFormat dof = CachingDateFormat.getDateOnlyFormat();
    Token candidate;
    while ((candidate = baseTokeniser.next()) != null)
    {
        Date date;
        if (candidate.termText().equalsIgnoreCase("now"))
        {
            date = new Date();
        }
        else if (candidate.termText().equalsIgnoreCase("today"))
        {
            date = new Date();
            Calendar cal = Calendar.getInstance();
            cal.setTime(date);
            cal.set(Calendar.HOUR_OF_DAY, cal.getMinimum(Calendar.HOUR_OF_DAY));
            cal.set(Calendar.MINUTE, cal.getMinimum(Calendar.MINUTE));
            cal.set(Calendar.SECOND, cal.getMinimum(Calendar.SECOND));
            cal.set(Calendar.MILLISECOND, cal.getMinimum(Calendar.MILLISECOND));
            
        }
        else
        {
            try
            {
                date = CachingDateFormat.lenientParse(candidate.termText(), Calendar.DAY_OF_MONTH).getFirst();
            }
            catch (ParseException e)
            {
                continue;
            }
        }
        String valueString = dof.format(date);
        Token integerToken = new Token(valueString, candidate.startOffset(), candidate.startOffset(), candidate.type());
        return integerToken;
    }
    return null;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:40,代码来源:DateTokenFilter.java

示例8: 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

示例9: 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

示例10: buildTrackerReport

import org.alfresco.util.CachingDateFormat; //导入依赖的package包/类
private NamedList<Object> buildTrackerReport(Tracker tracker, Long fromTx, Long toTx, Long fromAclTx, Long toAclTx, Long fromTime, Long toTime) throws IOException,
        JSONException, AuthenticationException
{
    IndexHealthReport indexHealthReport = tracker.checkIndex(fromTx, toTx, fromAclTx, toAclTx, fromTime, toTime);

    NamedList<Object> ihr = new SimpleOrderedMap<Object>();
    ihr.add("Alfresco version", tracker.getAlfrescoVersion());
    ihr.add("DB transaction count", indexHealthReport.getDbTransactionCount());
    ihr.add("DB acl transaction count", indexHealthReport.getDbAclTransactionCount());
    ihr.add("Count of duplicated transactions in the index", indexHealthReport.getDuplicatedTxInIndex().cardinality());
    if (indexHealthReport.getDuplicatedTxInIndex().cardinality() > 0)
    {
        ihr.add("First duplicate", indexHealthReport.getDuplicatedTxInIndex().nextSetBit(0L));
    }
    ihr.add("Count of duplicated acl transactions in the index", indexHealthReport.getDuplicatedAclTxInIndex().cardinality());
    if (indexHealthReport.getDuplicatedAclTxInIndex().cardinality() > 0)
    {
        ihr.add("First duplicate acl tx", indexHealthReport.getDuplicatedAclTxInIndex().nextSetBit(0L));
    }
    ihr.add("Count of transactions in the index but not the DB", indexHealthReport.getTxInIndexButNotInDb().cardinality());
    if (indexHealthReport.getTxInIndexButNotInDb().cardinality() > 0)
    {
        ihr.add("First transaction in the index but not the DB", indexHealthReport.getTxInIndexButNotInDb().nextSetBit(0L));
    }
    ihr.add("Count of acl transactions in the index but not the DB", indexHealthReport.getAclTxInIndexButNotInDb().cardinality());
    if (indexHealthReport.getAclTxInIndexButNotInDb().cardinality() > 0)
    {
        ihr.add("First acl transaction in the index but not the DB", indexHealthReport.getAclTxInIndexButNotInDb().nextSetBit(0L));
    }
    ihr.add("Count of missing transactions from the Index", indexHealthReport.getMissingTxFromIndex().cardinality());
    if (indexHealthReport.getMissingTxFromIndex().cardinality() > 0)
    {
        ihr.add("First transaction missing from the Index", indexHealthReport.getMissingTxFromIndex().nextSetBit(0L));
    }
    ihr.add("Count of missing acl transactions from the Index", indexHealthReport.getMissingAclTxFromIndex().cardinality());
    if (indexHealthReport.getMissingAclTxFromIndex().cardinality() > 0)
    {
        ihr.add("First acl transaction missing from the Index", indexHealthReport.getMissingAclTxFromIndex().nextSetBit(0L));
    }
    ihr.add("Index transaction count", indexHealthReport.getTransactionDocsInIndex());
    ihr.add("Index acl transaction count", indexHealthReport.getAclTransactionDocsInIndex());
    ihr.add("Index unique transaction count", indexHealthReport.getTransactionDocsInIndex());
    ihr.add("Index unique acl transaction count", indexHealthReport.getAclTransactionDocsInIndex());
    ihr.add("Index leaf count", indexHealthReport.getLeafDocCountInIndex());
    ihr.add("Count of duplicate leaves in the index", indexHealthReport.getDuplicatedLeafInIndex().cardinality());
    if (indexHealthReport.getDuplicatedLeafInIndex().cardinality() > 0)
    {
        ihr.add("First duplicate leaf in the index", "LEAF-" + indexHealthReport.getDuplicatedLeafInIndex().nextSetBit(0L));
    }
    ihr.add("Index aux count", indexHealthReport.getAuxDocCountInIndex());
    ihr.add("Count of duplicate aux docs in the index", indexHealthReport.getDuplicatedAuxInIndex().cardinality());
    if (indexHealthReport.getDuplicatedAuxInIndex().cardinality() > 0)
    {
        ihr.add("First duplicate aux in the index", "AUX-" + indexHealthReport.getDuplicatedAuxInIndex().nextSetBit(0L));
    }
    ihr.add("Index error count", indexHealthReport.getErrorDocCountInIndex());
    ihr.add("Count of duplicate error docs in the index", indexHealthReport.getDuplicatedErrorInIndex().cardinality());
    if (indexHealthReport.getDuplicatedErrorInIndex().cardinality() > 0)
    {
        ihr.add("First duplicate error in the index", "ERROR-" + indexHealthReport.getDuplicatedErrorInIndex().nextSetBit(0L));
    }
    ihr.add("Index unindexed count", indexHealthReport.getUnindexedDocCountInIndex());
    ihr.add("Count of duplicate unindexed docs in the index", indexHealthReport.getDuplicatedUnindexedInIndex().cardinality());
    if (indexHealthReport.getDuplicatedUnindexedInIndex().cardinality() > 0)
    {
        ihr.add("First duplicate unindexed in the index", "UNINDEXED-" + indexHealthReport.getDuplicatedErrorInIndex().nextSetBit(0L));
    }
    ihr.add("Last index commit time", indexHealthReport.getLastIndexedCommitTime());
    Date lastDate = new Date(indexHealthReport.getLastIndexedCommitTime());
    ihr.add("Last Index commit date", CachingDateFormat.getDateFormat().format(lastDate));
    ihr.add("Last TX id before holes", indexHealthReport.getLastIndexedIdBeforeHoles());
    return ihr;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:74,代码来源:AlfrescoCoreAdminHandler.java


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