<commit_before>package nl.topicus.jdbc.util;

import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.concurrent.TimeUnit;

import com.google.cloud.ByteArray;

public class CloudSpannerConversionUtil
{
	private CloudSpannerConversionUtil()
	{
	}

	public static Date toSqlDate(com.google.cloud.Date date)
	{
		return toSqlDate(date, Calendar.getInstance());
	}

	public static Date toSqlDate(com.google.cloud.Date date, Calendar cal)
	{
		cal.set(date.getYear(), date.getMonth() - 1, date.getDayOfMonth(), 0, 0, 0);
		cal.clear(Calendar.MILLISECOND);
		return new Date(cal.getTimeInMillis());
	}

	public static com.google.cloud.Date toCloudSpannerDate(Date date)
	{
		@SuppressWarnings("deprecation")
		com.google.cloud.Date res = com.google.cloud.Date.fromYearMonthDay(date.getYear() + 1900, date.getMonth() + 1,
				date.getDate());
		return res;
	}

	public static List<com.google.cloud.Date> toCloudSpannerDates(Date[] dates)
	{
		List<com.google.cloud.Date> res = new ArrayList<>(dates.length);
		for (int index = 0; index < dates.length; index++)
			res.add(toCloudSpannerDate(dates[index]));
		return res;
	}

	public static List<Date> toJavaDates(List<com.google.cloud.Date> dates)
	{
		List<Date> res = new ArrayList<>(dates.size());
		for (com.google.cloud.Date date : dates)
			res.add(CloudSpannerConversionUtil.toSqlDate(date));
		return res;
	}

	public static com.google.cloud.Timestamp toCloudSpannerTimestamp(Timestamp ts)
	{
		long milliseconds = ts.getTime();
		long seconds = milliseconds / 1000l;
		int rest = (int) (milliseconds % 1000l);
		int nanos = (int) TimeUnit.MILLISECONDS.toNanos(rest) + ts.getNanos();<commit_msg>large values for nanoseconds were counted twice<commit_after>package nl.topicus.jdbc.util;

import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.concurrent.TimeUnit;

import com.google.cloud.ByteArray;

public class CloudSpannerConversionUtil
{
	private CloudSpannerConversionUtil()
	{
	}

	public static Date toSqlDate(com.google.cloud.Date date)
	{
		return toSqlDate(date, Calendar.getInstance());
	}

	public static Date toSqlDate(com.google.cloud.Date date, Calendar cal)
	{
		cal.set(date.getYear(), date.getMonth() - 1, date.getDayOfMonth(), 0, 0, 0);
		cal.clear(Calendar.MILLISECOND);
		return new Date(cal.getTimeInMillis());
	}

	public static com.google.cloud.Date toCloudSpannerDate(Date date)
	{
		@SuppressWarnings("deprecation")
		com.google.cloud.Date res = com.google.cloud.Date.fromYearMonthDay(date.getYear() + 1900, date.getMonth() + 1,
				date.getDate());
		return res;
	}

	public static List<com.google.cloud.Date> toCloudSpannerDates(Date[] dates)
	{
		List<com.google.cloud.Date> res = new ArrayList<>(dates.length);
		for (int index = 0; index < dates.length; index++)
			res.add(toCloudSpannerDate(dates[index]));
		return res;
	}

	public static List<Date> toJavaDates(List<com.google.cloud.Date> dates)
	{
		List<Date> res = new ArrayList<>(dates.size());
		for (com.google.cloud.Date date : dates)
			res.add(CloudSpannerConversionUtil.toSqlDate(date));
		return res;
	}

	public static com.google.cloud.Timestamp toCloudSpannerTimestamp(Timestamp ts)
	{
		long milliseconds = ts.getTime();
		long seconds = milliseconds / 1000l;
		int nanos = ts.getNanos();
{'fraction_non_alphanumeric': 0.132986412257878, 'fraction_numerical': 0.009251228678808905, 'mean_word_length': 4.874363327674024, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, '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': '1115959', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1173, 'n_words': 240}