use of java.text.SimpleDateFormat in project elastic-job by dangdangdotcom.
the class StatisticRdbRepository method findJobRunningStatistics.
/**
* 获取运行中的任务统计数据集合.
*
* @param from 统计开始时间
* @return 运行中的任务统计数据集合
*/
public List<JobRunningStatistics> findJobRunningStatistics(final Date from) {
List<JobRunningStatistics> result = new LinkedList<>();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String sql = String.format("SELECT id, running_count, statistics_time, creation_time FROM %s WHERE statistics_time >= '%s' order by id ASC", TABLE_JOB_RUNNING_STATISTICS, formatter.format(from));
try (Connection conn = dataSource.getConnection();
PreparedStatement preparedStatement = conn.prepareStatement(sql);
ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
JobRunningStatistics jobRunningStatistics = new JobRunningStatistics(resultSet.getLong(1), resultSet.getInt(2), new Date(resultSet.getTimestamp(3).getTime()), new Date(resultSet.getTimestamp(4).getTime()));
result.add(jobRunningStatistics);
}
} catch (final SQLException ex) {
// TODO 记录失败直接输出日志,未来可考虑配置化
log.error("Fetch jobRunningStatistics from DB error:", ex);
}
return result;
}
use of java.text.SimpleDateFormat in project elastic-job by dangdangdotcom.
the class StatisticRdbRepository method findTaskResultStatistics.
/**
* 获取任务运行结果统计数据集合.
*
* @param from 统计开始时间
* @param statisticInterval 统计时间间隔
* @return 任务运行结果统计数据集合
*/
public List<TaskResultStatistics> findTaskResultStatistics(final Date from, final StatisticInterval statisticInterval) {
List<TaskResultStatistics> result = new LinkedList<>();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String sql = String.format("SELECT id, success_count, failed_count, statistics_time, creation_time FROM %s WHERE statistics_time >= '%s' order by id ASC", TABLE_TASK_RESULT_STATISTICS + "_" + statisticInterval, formatter.format(from));
try (Connection conn = dataSource.getConnection();
PreparedStatement preparedStatement = conn.prepareStatement(sql);
ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
TaskResultStatistics taskResultStatistics = new TaskResultStatistics(resultSet.getLong(1), resultSet.getInt(2), resultSet.getInt(3), statisticInterval, new Date(resultSet.getTimestamp(4).getTime()), new Date(resultSet.getTimestamp(5).getTime()));
result.add(taskResultStatistics);
}
} catch (final SQLException ex) {
// TODO 记录失败直接输出日志,未来可考虑配置化
log.error("Fetch taskResultStatistics from DB error:", ex);
}
return result;
}
use of java.text.SimpleDateFormat in project Meizhi by drakeet.
the class FloatView method setNotification.
public void setNotification(final HeadsUp headsUp) {
this.headsUp = headsUp;
mHandle = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (headsUp.isActivateStatusBar()) {
HeadsUpManager.getInstant(getContext()).silencerNotify(headsUp);
}
HeadsUpManager.getInstant(getContext()).animDismiss(headsUp);
}
};
cutDownTime = new CutDownTime();
if (!headsUp.isSticky()) {
cutDownTime.start();
}
cutDown = headsUp.getDuration();
if (headsUp.getCustomView() == null) {
View defaultView = LayoutInflater.from(getContext()).inflate(R.layout.notification, rootView, false);
rootView.addView(defaultView);
ImageView imageView = (ImageView) defaultView.findViewById(R.id.iconIM);
TextView titleTV = (TextView) defaultView.findViewById(R.id.titleTV);
TextView timeTV = (TextView) defaultView.findViewById(R.id.timeTV);
TextView messageTV = (TextView) defaultView.findViewById(R.id.messageTV);
imageView.setImageResource(headsUp.getIcon());
titleTV.setText(headsUp.getTitleStr());
messageTV.setText(headsUp.getMsgStr());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
timeTV.setText(simpleDateFormat.format(new Date()));
if (headsUp.isExpand() && headsUp.getActions().size() > 0) {
defaultView.findViewById(R.id.menuL).setVisibility(VISIBLE);
defaultView.findViewById(R.id.line).setVisibility(VISIBLE);
defaultView.findViewById(R.id.menu1).setVisibility(VISIBLE);
ImageView imageView1 = (ImageView) defaultView.findViewById(R.id.menuIM1);
ImageView imageView2 = (ImageView) defaultView.findViewById(R.id.menuIM2);
ImageView imageView3 = (ImageView) defaultView.findViewById(R.id.menuIM3);
TextView text1 = (TextView) defaultView.findViewById(R.id.menuText1);
TextView text2 = (TextView) defaultView.findViewById(R.id.menuText2);
TextView text3 = (TextView) defaultView.findViewById(R.id.menuText3);
imageView1.setImageResource(headsUp.getActions().get(0).icon);
text1.setText(headsUp.getActions().get(0).title);
defaultView.findViewById(R.id.menu1).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
headsUp.getActions().get(0).actionIntent.send();
cancel();
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
}
});
if (headsUp.getActions().size() > 1) {
defaultView.findViewById(R.id.menu2).setVisibility(VISIBLE);
imageView2.setImageResource(headsUp.getActions().get(1).icon);
text2.setText(headsUp.getActions().get(1).title);
defaultView.findViewById(R.id.menu2).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
headsUp.getActions().get(1).actionIntent.send();
cancel();
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
}
});
}
if (headsUp.getActions().size() > 2) {
defaultView.findViewById(R.id.menu3).setVisibility(VISIBLE);
imageView3.setImageResource(headsUp.getActions().get(2).icon);
text3.setText(headsUp.getActions().get(2).title);
defaultView.findViewById(R.id.menu3).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
headsUp.getActions().get(2).actionIntent.send();
cancel();
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
}
});
}
}
} else {
setCustomView(headsUp.getCustomView());
}
}
use of java.text.SimpleDateFormat in project UltimateAndroid by cymcsg.
the class PatioUtils method getNewImageFile.
public static File getNewImageFile() throws IOException {
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
return File.createTempFile(imageFileName, ".jpg", storageDir);
}
use of java.text.SimpleDateFormat in project UltimateAndroid by cymcsg.
the class FileUtils method createTmpFile.
public static File createTmpFile(Context context) {
String state = Environment.getExternalStorageState();
if (state.equals(Environment.MEDIA_MOUNTED)) {
// 已挂载
File pic = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date());
String fileName = "multi_image_" + timeStamp + "";
File tmpFile = new File(pic, fileName + ".jpg");
return tmpFile;
} else {
File cacheDir = context.getCacheDir();
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date());
String fileName = "multi_image_" + timeStamp + "";
File tmpFile = new File(cacheDir, fileName + ".jpg");
return tmpFile;
}
}
Aggregations