<commit_before>package com.levelup.java.date.format;

import static org.junit.Assert.assertEquals;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.junit.Test;

/**
 * This java example will demonstrate formatting a date of January 15, 1967.
 * 
 * @author <NAME>
 * @see <a href='http://www.leveluplunch.com/java/examples/format-date/'></a>
 * 
 */
public class FormatDate {
	
	@Test
	public void format_date_in_java () {
		
		Calendar cal = Calendar.getInstance();
		cal.set(Calendar.MONTH, Calendar.JANUARY);
		cal.set(Calendar.DAY_OF_MONTH, 15);
		cal.set(Calendar.YEAR, 1967);

		// http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
		SimpleDateFormat dateFormatter = new SimpleDateFormat("MM/dd/yyyy");
		String dateFirstSuperBowlWasPlayed = dateFormatter.format(cal.getTime());
		
		// dateFirstSuperBowlWasPlayed = 01/15/1967
		assertEquals("01/15/1967", dateFirstSuperBowlWasPlayed);
		
	}
	
	@Test
	public void format_date_in_java_using_printf() {

		Calendar cal = Calendar.getInstance();
		cal.set(Calendar.MONTH, Calendar.JANUARY);
		cal.set(Calendar.DAY_OF_MONTH, 15);
		cal.set(Calendar.YEAR, 1967);
		cal.set(Calendar.HOUR, 0);
		cal.set(Calendar.SECOND, 0);
		cal.set(Calendar.MINUTE, 0);
		cal.set(Calendar.MILLISECOND, 0);

		// display time and date using toString()
		String str = String.format("Current Date/Time : %tc", cal.getTime());
		
		assertEquals("Current Date/Time : Sun Jan 15 12:00:00 CST 1967", str);
	}
	
	
	@Test
	public void format_date_in_java_with_joda () {
		
		DateTime dateFirstSuperBowlWasPlayed = new DateTime(1967, 1, 15, 0, 0);

		DateTimeFormatter fmt = DateTimeFormat.forPattern("MM/dd/yyyy");
		
		assertEquals("01/15/1967", dateFirstSuperBowlWasPlayed.toString(fmt));

	}
	
	@Test
	public void format_date_in_java_with_apachecommons () {
		Calendar cal = Calendar.getInstance();
		cal.set(Calendar.MONTH, Calendar.JANUARY);
		cal.set(Calendar.DAY_OF_MONTH, 15);
		cal.set(Calendar.YEAR, 1967);

		String dateFirstSuperBowlWasPlayed = DateFormatUtils.format(cal, "MM/dd/yyyy");
		assertEquals("01/15/1967", dateFirstSuperBowlWasPlayed);
	}
	
	

}<commit_msg>format date added url, etc<commit_after>package com.levelup.java.date.format;

import static org.junit.Assert.assertEquals;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.junit.Test;

/**
 * This java example will demonstrate formatting a date of January 15, 1967.
 * 
 * @author <NAME>
 * @see <a href='http://www.leveluplunch.com/java/examples/format-date/'>Format date</a>
 * 
 */
public class FormatDate {
	
	@Test
	public void format_date_in_java () {
		
		Calendar cal = Calendar.getInstance();
		cal.set(Calendar.MONTH, Calendar.JANUARY);
		cal.set(Calendar.DAY_OF_MONTH, 15);
		cal.set(Calendar.YEAR, 1967);

		SimpleDateFormat dateFormatter = new SimpleDateFormat("MM/dd/yyyy");
		String dateFirstSuperBowlWasPlayed = dateFormatter.format(cal.getTime());
		
		assertEquals("01/15/1967", dateFirstSuperBowlWasPlayed);
	}
	
	@Test
	public void format_date_in_java_using_string_format() {

		Calendar cal = Calendar.getInstance();
		cal.set(Calendar.MONTH, Calendar.JANUARY);
		cal.set(Calendar.DAY_OF_MONTH, 15);
		cal.set(Calendar.YEAR, 1967);
		cal.set(Calendar.HOUR, 0);
		cal.set(Calendar.SECOND, 0);
		cal.set(Calendar.MINUTE, 0);
		cal.set(Calendar.MILLISECOND, 0);

		String str = String.format("Current Date/Time : %tc", cal.getTime());
		
		assertEquals("Current Date/Time : Sun Jan 15 12:00:00 CST 1967", str);
	}
	
	
	@Test
	public void format_date_in_java_with_joda () {
		
		DateTime dateFirstSuperBowlWasPlayed = new DateTime(1967, 1, 15, 0, 0);

		DateTimeFormatter fmt = DateTimeFormat.forPattern("MM/dd/yyyy");
		
		assertEquals("01/15/1967", dateFirstSuperBowlWasPlayed.toString(fmt));
	}
	
	@Test
	public void format_date_in_java_with_apachecommons () {
		Calendar cal = Calendar.getInstance();
		cal.set(Calendar.MONTH, Calendar.JANUARY);
		cal.set(Calendar.DAY_OF_MONTH, 15);
		cal.set(Calendar.YEAR, 1967);

		String dateFirstSuperBowlWasPlayed = DateFormatUtils.format(cal, "MM/dd/yyyy");
		assertEquals("01/15/1967", dateFirstSuperBowlWasPlayed);
	}
	
	

}
{'fraction_non_alphanumeric': 0.13243422507185496, 'fraction_numerical': 0.03471147468494362, 'mean_word_length': 4.7484116899618805, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6813805', 'n_tokens_mistral': 1810, 'n_tokens_neox': 1520, 'n_words': 280}