<commit_before>package com.blankj.utilcode.util;

import com.blankj.utilcode.constant.TimeConstants;

import org.junit.Test;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;


/**
 * <pre>
 *     author: Blankj
 *     blog  : http://blankj.com
 *     time  : 2016/08/12
 *     desc  : TimeUtils单元测试
 * </pre>
 */
public class TimeUtilsTest {

    private final DateFormat defaultFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
    private final DateFormat mFormat       = new SimpleDateFormat("yyyy MM dd HH:mm:ss", Locale.getDefault());

    private final long   timeMillis               = 1493887049000L;
    private final Date   timeDate                 = new Date(timeMillis);
    private final String timeString               = defaultFormat.format(timeDate);
    private final String timeStringFormat         = mFormat.format(timeDate);
    private final long   tomorrowTimeMillis       = 1493973449000L;
    private final Date   tomorrowTimeDate         = new Date(tomorrowTimeMillis);
    private final String tomorrowTimeString       = defaultFormat.format(tomorrowTimeDate);
    private final String tomorrowTimeStringFormat = mFormat.format(tomorrowTimeDate);
    private final long   delta                    = 1;// 允许误差1ms

    @Test
    public void millis2String() throws Exception {
        assertEquals(timeString, TimeUtils.millis2String(timeMillis));
        assertEquals(timeStringFormat, TimeUtils.millis2String(timeMillis, mFormat));
    }

    @Test
    public void string2Millis() throws Exception {
        assertEquals(timeMillis, TimeUtils.string2Millis(timeString));
        assertEquals(timeMillis, TimeUtils.string2Millis(timeStringFormat, mFormat));
    }

    @Test
    public void string2Date() throws Exception {
        assertEquals(timeDate, TimeUtils.string2Date(timeString));
        assertEquals(timeDate, TimeUtils.string2Date(timeStringFormat, mFormat));
    }

    @Test
    public void date2String() throws Exception {
        assertEquals(timeString, TimeUtils.date2String(timeDate));
        assertEquals(timeStringFormat, TimeUtils.date2String(timeDate, mFormat));
    }
<commit_msg>see 06/09 log<commit_after>package com.blankj.utilcode.util;

import com.blankj.utilcode.constant.TimeConstants;

import org.junit.Test;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;


/**
 * <pre>
 *     author: Blankj
 *     blog  : http://blankj.com
 *     time  : 2016/08/12
 *     desc  : TimeUtils单元测试
 * </pre>
 */
public class TimeUtilsTest {

    private final DateFormat defaultFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
    private final DateFormat mFormat       = new SimpleDateFormat("yyyy MM dd HH:mm:ss", Locale.getDefault());

    private final long   timeMillis               = 1493887049000L;
    private final Date   timeDate                 = new Date(timeMillis);
    private final String timeString               = defaultFormat.format(timeDate);
    private final String timeStringFormat         = mFormat.format(timeDate);
    private final long   tomorrowTimeMillis       = 1493973449000L;
    private final Date   tomorrowTimeDate         = new Date(tomorrowTimeMillis);
    private final String tomorrowTimeString       = defaultFormat.format(tomorrowTimeDate);
    private final String tomorrowTimeStringFormat = mFormat.format(tomorrowTimeDate);
    private final long   delta                    = 2;// 允许误差2ms

    @Test
    public void millis2String() throws Exception {
        assertEquals(timeString, TimeUtils.millis2String(timeMillis));
        assertEquals(timeStringFormat, TimeUtils.millis2String(timeMillis, mFormat));
    }

    @Test
    public void string2Millis() throws Exception {
        assertEquals(timeMillis, TimeUtils.string2Millis(timeString));
        assertEquals(timeMillis, TimeUtils.string2Millis(timeStringFormat, mFormat));
    }

    @Test
    public void string2Date() throws Exception {
        assertEquals(timeDate, TimeUtils.string2Date(timeString));
        assertEquals(timeDate, TimeUtils.string2Date(timeStringFormat, mFormat));
    }

    @Test
    public void date2String() throws Exception {
        assertEquals(timeString, TimeUtils.date2String(timeDate));
        assertEquals(timeStringFormat, TimeUtils.date2String(timeDate, mFormat));
    }

{'fraction_non_alphanumeric': 0.08864795918367346, 'fraction_numerical': 0.021258503401360544, 'mean_word_length': 3.4219924812030076, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5831897', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1308, 'n_words': 294}