Search in sources :

Example 21 with GregorianCalendar

use of java.util.GregorianCalendar in project lucida by claritylab.

the class EphyraTREC13To16 method main.

/**
	 * Runs Ephyra on the TREC questions.
	 * 
	 * @param args argument 1: questionfile<br>
	 * 			   [argument 2: tag=runtag (uniquely identifies the run, also
	 * 							used as output file name, if not set an
	 * 							unambiguous tag is generated automatically)]<br>
	 * 			   [argument 3: log=logfile (if not set an unambiguous file name
	 * 							is generated automatically)]<br>
	 * 			   [argument 4: lin=input_logfile (specifies a separate logfile
	 * 							that is used as a source for answers to some of
	 * 							the	questions, if not set the standard log file
	 * 							is used)]<br>
	 * 			   [argument 5: lflags=[f][l][o] (answers to these types of
	 * 							questions are loaded from the log file instead
	 * 							of querying Ephyra,	e.g. "flo" for factoid, list
	 * 							and other questions)]<br>
	 * 			   [argument 6: fp=factoid_patternfile]<br>
	 * 			   [argument 7: lp=list_patternfile]
	 */
public static void main(String[] args) {
    // enable output of status and error messages
    MsgPrinter.enableStatusMsgs(true);
    MsgPrinter.enableErrorMsgs(true);
    if (args.length < 1) {
        MsgPrinter.printUsage("java EphyraTREC13To16 questionfile " + "[tag=runtag] [log=logfile] " + "[lin=input_logfile] " + "[lflags=[f][l][o]] " + "[fp=factoid_patternfile] " + "[lp=list_patternfile]");
        System.exit(1);
    }
    // load targets
    targets = TREC13To16Parser.loadTargets(args[0]);
    for (int i = 1; i < args.length; i++) if (args[i].matches("tag=.*")) {
        // set run tag
        runTag = args[i].substring(4);
    } else if (args[i].matches("log=.*")) {
        // set log file
        logFile = args[i].substring(4);
    } else if (args[i].matches("lin=.*")) {
        // set separate input log file
        inputLogFile = args[i].substring(4);
    } else if (args[i].matches("lflags=.*")) {
        // answers for some question types are loaded from log file
        String flags = args[i].substring(7).toLowerCase();
        if (flags.contains("f"))
            factoidLog = true;
        if (flags.contains("l"))
            listLog = true;
        if (flags.contains("o"))
            otherLog = true;
    } else if (args[i].matches("fp=.*")) {
        // load factoid patterns
        factoidPatterns = TREC13To16Parser.loadPatterns(args[i].substring(3));
    } else if (args[i].matches("lp=.*")) {
        // load list patterns
        listPatterns = TREC13To16Parser.loadPatterns(args[i].substring(3));
    }
    // if run tag or log file not set, generate unambiguous names
    if (runTag == null || logFile == null) {
        String n = "";
        Matcher m = Pattern.compile("\\d++").matcher(args[0]);
        if (m.find())
            n = m.group(0);
        String date = "";
        Calendar c = new GregorianCalendar();
        date += c.get(Calendar.DAY_OF_MONTH);
        if (date.length() == 1)
            date = "0" + date;
        date = (c.get(Calendar.MONTH) + 1) + date;
        if (date.length() == 3)
            date = "0" + date;
        date = c.get(Calendar.YEAR) + date;
        if (runTag == null)
            runTag = "TREC" + n + "_" + date + "_out";
        if (logFile == null)
            logFile = "log/TREC" + n + "_" + date;
    }
    // if input log file not set, use standard log file
    if (inputLogFile == null)
        inputLogFile = logFile;
    // enable logging
    Logger.setLogfile(logFile);
    Logger.enableLogging(true);
    // run Ephyra on questions, evaluate answers if patterns available
    runAndEval();
}
Also used : Matcher(java.util.regex.Matcher) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar)

Example 22 with GregorianCalendar

use of java.util.GregorianCalendar in project jetty.project by eclipse.

the class SecureModeServlet method runLoggingChecks.

private void runLoggingChecks(ServletOutputStream out) throws Exception {
    out.println("    <h1>Checking File System</h1>");
    out.println("      <p>");
    String userDir = System.getProperty("user.dir");
    try {
        out.println("check ability to log<br/>");
        LOG.info("testing logging");
        out.println("status: <b>SUCCESS - expected</b><br/>");
    } catch (SecurityException e) {
        out.println("status: <b>FAILURE - unexpected</b><br/>");
        out.println("<table><tr><td>");
        e.printStackTrace(new PrintStream(out));
        out.println("</td></tr></table>");
    }
    try {
        Calendar c = new GregorianCalendar();
        String logFile = c.get(Calendar.YEAR) + "_" + c.get(Calendar.MONTH) + "_" + c.get(Calendar.DAY_OF_MONTH) + ".request.log";
        out.println("check ability to access log file directly<br/>");
        File jettyHomeFile = new File(userDir + File.separator + "logs" + File.separator + logFile);
        jettyHomeFile.canRead();
        out.println("status: <b>SUCCESS - unexpected</b><br/>");
    } catch (SecurityException e) {
        out.println("status: <b>FAILURE - expected</b><br/>");
    }
    out.println("      </p><br/><br/>");
}
Also used : PrintStream(java.io.PrintStream) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) File(java.io.File)

Example 23 with GregorianCalendar

use of java.util.GregorianCalendar in project android-app by eoecn.

the class DateUtil method getDateObj.

/**
	 * 取得指定年月日的日期对象.
	 * 
	 * @param year
	 *            年
	 * @param month
	 *            月注意是从1到12
	 * @param day
	 *            日
	 * @return 一个java.util.Date()类型的对象
	 */
public static Date getDateObj(int year, int month, int day) {
    Calendar c = new GregorianCalendar();
    c.set(year, month - 1, day);
    return c.getTime();
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar)

Example 24 with GregorianCalendar

use of java.util.GregorianCalendar in project android-app by eoecn.

the class DateUtil method getWeekOfYear.

/**
	 * 返回制定日期所在的周是一年中的第几个周。<br>
	 * created by wangmj at 20060324.<br>
	 * 
	 * @param year
	 * @param month
	 *            范围1-12<br>
	 * @param day
	 * @return int 
	 */
public static int getWeekOfYear(String year, String month, String day) {
    Calendar cal = new GregorianCalendar();
    cal.clear();
    cal.set(new Integer(year).intValue(), new Integer(month).intValue() - 1, new Integer(day).intValue());
    return cal.get(Calendar.WEEK_OF_YEAR);
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar)

Example 25 with GregorianCalendar

use of java.util.GregorianCalendar in project android-app by eoecn.

the class DateUtil method getFormatDateAdd.

/**
	 * 取得给定日期加上一定天数后的日期对象.
	 * 
	 * @param date
	 *            给定的日期对象
	 * @param amount
	 *            需要添加的天数,如果是向前的天数,使用负数就可以.
	 * @param format
	 *            输出格式.
	 * @return Date 加上一定天数以后的Date对象.
	 */
public static String getFormatDateAdd(Date date, int amount, String format) {
    Calendar cal = new GregorianCalendar();
    cal.setTime(date);
    cal.add(GregorianCalendar.DATE, amount);
    return getFormatDateTime(cal.getTime(), format);
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar)

Aggregations

GregorianCalendar (java.util.GregorianCalendar)1212 Calendar (java.util.Calendar)574 Date (java.util.Date)358 Test (org.junit.Test)233 SimpleDateFormat (java.text.SimpleDateFormat)100 Timestamp (java.sql.Timestamp)54 ScheduleExpression (javax.ejb.ScheduleExpression)51 ArrayList (java.util.ArrayList)47 EJBCronTrigger (org.apache.openejb.core.timer.EJBCronTrigger)42 HashMap (java.util.HashMap)41 ParseException (java.text.ParseException)38 TimeZone (java.util.TimeZone)38 SimpleTimeZone (java.util.SimpleTimeZone)35 BigDecimal (java.math.BigDecimal)32 Date (java.sql.Date)30 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)21 DateFormat (java.text.DateFormat)18 SQLException (java.sql.SQLException)17 Map (java.util.Map)16 Meeting (net.johnpwood.android.standuptimer.model.Meeting)16