Search in sources :

Example 71 with SimpleDateFormat

use of java.text.SimpleDateFormat in project weixin-java-tools by chanjarster.

the class WxMpMiscAPITest method testGetUserCumulate.

@Test
public void testGetUserCumulate() throws WxErrorException, ParseException {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    Date beginDate = simpleDateFormat.parse("2015-01-01");
    Date endDate = simpleDateFormat.parse("2015-01-02");
    List<WxMpUserCumulate> cumulates = wxService.getUserCumulate(beginDate, endDate);
    System.out.println(cumulates);
    Assert.assertNotNull(cumulates);
}
Also used : WxMpUserCumulate(me.chanjar.weixin.mp.bean.result.WxMpUserCumulate) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 72 with SimpleDateFormat

use of java.text.SimpleDateFormat in project deeplearning4j by deeplearning4j.

the class SerializingListener method processEvent.

/**
     * This method is called at each epoch end
     *
     * @param event
     * @param sequenceVectors
     * @param argument
     */
@Override
public void processEvent(ListenerEvent event, SequenceVectors<T> sequenceVectors, long argument) {
    try {
        locker.acquire();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        StringBuilder builder = new StringBuilder(targetFolder.getAbsolutePath());
        builder.append("/").append(modelPrefix).append("_").append(sdf.format(new Date())).append(".seqvec");
        File targetFile = new File(builder.toString());
        if (useBinarySerialization) {
            SerializationUtils.saveObject(sequenceVectors, targetFile);
        } else {
            throw new UnsupportedOperationException("Not implemented yet");
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        locker.release();
    }
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) Date(java.util.Date)

Example 73 with SimpleDateFormat

use of java.text.SimpleDateFormat in project PhotoPicker by donglua.

the class ImageCaptureManager method createImageFile.

private File createImageFile() throws IOException {
    // Create an image file name
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.ENGLISH).format(new Date());
    String imageFileName = "JPEG_" + timeStamp + ".jpg";
    File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
    if (!storageDir.exists()) {
        if (!storageDir.mkdir()) {
            Log.e("TAG", "Throwing Errors....");
            throw new IOException();
        }
    }
    File image = new File(storageDir, imageFileName);
    // Save a file: path for use with ACTION_VIEW intents
    mCurrentPhotoPath = image.getAbsolutePath();
    return image;
}
Also used : IOException(java.io.IOException) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) Date(java.util.Date)

Example 74 with SimpleDateFormat

use of java.text.SimpleDateFormat in project presentations by eburke.

the class LocationSubscribeFragment method showLocation.

private void showLocation(Location location) {
    if (location == null) {
        locationTextView.setText("No Location");
    } else {
        locationTextView.setText(location.toString());
    }
    // Update the timestamp so the user sees some kind of update even if the location didn't change.
    SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
    timestampTextView.setText(dateFormat.format(new Date()));
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 75 with SimpleDateFormat

use of java.text.SimpleDateFormat in project elastic-job by dangdangdotcom.

the class StatisticRdbRepository method getSummedTaskResultStatistics.

/**
     * 获取合计后的任务运行结果统计数据.
     * 
     * @param from 统计开始时间
     * @param statisticInterval 统计时间间隔
     * @return 合计后的任务运行结果统计数据对象
     */
public TaskResultStatistics getSummedTaskResultStatistics(final Date from, final StatisticInterval statisticInterval) {
    TaskResultStatistics result = new TaskResultStatistics(0, 0, statisticInterval, new Date());
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String sql = String.format("SELECT sum(success_count), sum(failed_count) FROM %s WHERE statistics_time >= '%s'", 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()) {
            result = new TaskResultStatistics(resultSet.getInt(1), resultSet.getInt(2), statisticInterval, new Date());
        }
    } catch (final SQLException ex) {
        // TODO 记录失败直接输出日志,未来可考虑配置化
        log.error("Fetch summed 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) 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