Search in sources :

Example 76 with SimpleDateFormat

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;
}
Also used : SQLException(java.sql.SQLException) JobRunningStatistics(com.dangdang.ddframe.job.statistics.type.job.JobRunningStatistics) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SimpleDateFormat(java.text.SimpleDateFormat) LinkedList(java.util.LinkedList) Date(java.util.Date)

Example 77 with SimpleDateFormat

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;
}
Also used : TaskResultStatistics(com.dangdang.ddframe.job.statistics.type.task.TaskResultStatistics) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SimpleDateFormat(java.text.SimpleDateFormat) LinkedList(java.util.LinkedList) Date(java.util.Date)

Example 78 with SimpleDateFormat

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());
    }
}
Also used : Message(android.os.Message) Handler(android.os.Handler) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 79 with SimpleDateFormat

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);
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) Date(java.util.Date)

Example 80 with SimpleDateFormat

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;
    }
}
Also used : File(java.io.File) 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