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)));
}
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);
}
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));
}
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));
}
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();
}
Aggregations