Search in sources :

Example 46 with SimpleDateFormat

use of java.text.SimpleDateFormat in project hive by apache.

the class Function method execCurrentDate.

/**
   * Get the current date
   */
public void execCurrentDate(HplsqlParser.Expr_spec_funcContext ctx) {
    if (trace) {
        trace(ctx, "CURRENT_DATE");
    }
    SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
    String s = f.format(Calendar.getInstance().getTime());
    exec.stackPush(new Var(Var.Type.DATE, Utils.toDate(s)));
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat)

Example 47 with SimpleDateFormat

use of java.text.SimpleDateFormat in project hive by apache.

the class FunctionDatetime method currentTimestamp.

public static Var currentTimestamp(int precision) {
    String format = "yyyy-MM-dd HH:mm:ss";
    if (precision > 0 && precision <= 3) {
        format += "." + StringUtils.repeat("S", precision);
    }
    SimpleDateFormat f = new SimpleDateFormat(format);
    String s = f.format(Calendar.getInstance(TimeZone.getDefault()).getTime());
    return new Var(Utils.toTimestamp(s), precision);
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat)

Example 48 with SimpleDateFormat

use of java.text.SimpleDateFormat in project hive by apache.

the class FunctionDatetime method currentDate.

public static Var currentDate() {
    SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
    String s = f.format(Calendar.getInstance().getTime());
    return new Var(Var.Type.DATE, Utils.toDate(s));
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat)

Example 49 with SimpleDateFormat

use of java.text.SimpleDateFormat in project tomcat by apache.

the class Response method setDateHeader.

/**
     * Set the specified date header to the specified value.
     *
     * @param name Name of the header to set
     * @param value Date value to be set
     */
@Override
public void setDateHeader(String name, long value) {
    if (name == null || name.length() == 0) {
        return;
    }
    if (isCommitted()) {
        return;
    }
    // Ignore any call from an included servlet
    if (included) {
        return;
    }
    if (format == null) {
        format = new SimpleDateFormat(FastHttpDateFormat.RFC1123_DATE, Locale.US);
        format.setTimeZone(TimeZone.getTimeZone("GMT"));
    }
    setHeader(name, FastHttpDateFormat.formatDate(value, format));
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat)

Example 50 with SimpleDateFormat

use of java.text.SimpleDateFormat in project tomcat by apache.

the class AccessLogValve method startInternal.

/**
     * Start this component and implement the requirements
     * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
     *
     * @exception LifecycleException if this component detects a fatal error
     *  that prevents this component from being used
     */
@Override
protected synchronized void startInternal() throws LifecycleException {
    // Initialize the Date formatters
    String format = getFileDateFormat();
    fileDateFormatter = new SimpleDateFormat(format, Locale.US);
    fileDateFormatter.setTimeZone(TimeZone.getDefault());
    dateStamp = fileDateFormatter.format(new Date(System.currentTimeMillis()));
    if (rotatable && renameOnRotate) {
        restore();
    }
    open();
    super.startInternal();
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

SimpleDateFormat (java.text.SimpleDateFormat)2847 Date (java.util.Date)1590 ParseException (java.text.ParseException)463 DateFormat (java.text.DateFormat)425 Calendar (java.util.Calendar)307 Test (org.junit.Test)305 ArrayList (java.util.ArrayList)232 File (java.io.File)230 IOException (java.io.IOException)185 GregorianCalendar (java.util.GregorianCalendar)139 HashMap (java.util.HashMap)121 Locale (java.util.Locale)70 DateField (edu.uci.ics.textdb.api.field.DateField)64 DoubleField (edu.uci.ics.textdb.api.field.DoubleField)64 IField (edu.uci.ics.textdb.api.field.IField)64 IntegerField (edu.uci.ics.textdb.api.field.IntegerField)64 StringField (edu.uci.ics.textdb.api.field.StringField)63 TextField (edu.uci.ics.textdb.api.field.TextField)63 Map (java.util.Map)63 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)61