<commit_before>package edu.duke.cabig.c3pr.utils;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import org.acegisecurity.Authentication;
import org.acegisecurity.GrantedAuthority;
import org.acegisecurity.context.SecurityContext;
import org.acegisecurity.context.SecurityContextHolder;
import org.acegisecurity.userdetails.User;

import com.karneim.util.collection.regex.ParseException;

public class CommonUtils {

	public static String getLoggedInUsername() {
        SecurityContext context = SecurityContextHolder.getContext();
        Authentication auth = context.getAuthentication();
        if (auth != null) {
            return ((User)auth.getPrincipal()).getUsername();
        }
        return "";
    }
	
    public static String getDateString(Date date){
      if (date != null) {
    	  	try{
			return DateUtil.formatDate(date, "MM/dd/yyyy");
    	  	}catch (ParseException e) {
			}
		}
		return "";
    }


    public static Date getOldDate(Date date, int days){
		GregorianCalendar cal = new GregorianCalendar();
		cal.setTime(date);
		cal.add(Calendar.DATE, days);
		return cal.getTime();

    }

//    public static void main(String args[]){
//    	Calendar cal = Calendar.getInstance();
//        cal.add(Calendar.DATE, -1);
//        System.out.println(cal.getTime());
//    }


}<commit_msg>added method to get error messages as a list <commit_after>package edu.duke.cabig.c3pr.utils;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;

import org.acegisecurity.Authentication;
import org.acegisecurity.context.SecurityContext;
import org.acegisecurity.context.SecurityContextHolder;
import org.acegisecurity.userdetails.User;

import edu.duke.cabig.c3pr.domain.Error;


public class CommonUtils {

	public static String getLoggedInUsername() {
        SecurityContext context = SecurityContextHolder.getContext();
        Authentication auth = context.getAuthentication();
        if (auth != null) {
            return ((User)auth.getPrincipal()).getUsername();
        }
        return "";
    }
	
    public static String getDateString(Date date){
      if (date != null) {
    	  		return DateUtil.formatDate(date, "MM/dd/yyyy");
		}
		return "";
    }


    public static Date getOldDate(Date date, int days){
		GregorianCalendar cal = new GregorianCalendar();
		cal.setTime(date);
		cal.add(Calendar.DATE, days);
		return cal.getTime();

    }

    public static String listErrors(List<Error> errors){
    	
    	StringBuffer sb = new StringBuffer();
    	for(int i=0;i< errors.size();i++){
    		sb.append(i + "." + " " + errors.get(i).getErrorMessage());
    	}
    	return sb.toString();
    }


}
{'fraction_non_alphanumeric': 0.12115666178623719, 'fraction_numerical': 0.0018301610541727673, 'mean_word_length': 3.3380952380952382, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '5529613', 'n_tokens_mistral': 883, 'n_tokens_neox': 832, 'n_words': 174}