package it.cnr.iasi.giant.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.regex.Pattern;

/**
 *
 * @author Fabio Cumbo
 * @info GIANT
 * @version v1.0
 * @organization IASI-CNR : Istituto di Analisi dei Sistemi ed Informatica 
 *                  "Antonio Ruberti" - Consiglio Nazionale delle Ricerche
 * 
 */

public class Helper {
	
	private final static String fileTabREGEX = "\t";
        private final static String fileSpaceREGEX = " ";
	
	public Helper() {}
	
	public ArrayList<String> tabPattern(String string) {
		ArrayList<String> completeList = new ArrayList<String>();
		Pattern pattern = Pattern.compile(fileTabREGEX);
                completeList.addAll(Arrays.asList(pattern.split(string)));
		return completeList;
	}
        
        public ArrayList<String> spacePattern(String string) {
		ArrayList<String> completeList = new ArrayList<String>();
		Pattern pattern = Pattern.compile(fileSpaceREGEX);
                completeList.addAll(Arrays.asList(pattern.split(string)));
		return completeList;
	}
        
        public static String getCurrentTime() {
		Calendar calendar = new GregorianCalendar();
		int day = calendar.get(Calendar.DAY_OF_MONTH);
		int month = calendar.get(Calendar.MONTH)+1;
		int year = calendar.get(Calendar.YEAR);
		int hour = calendar.get(Calendar.HOUR);
		int minute = calendar.get(Calendar.MINUTE);
		int second = calendar.get(Calendar.SECOND);
		String AM_PM;
		if(calendar.get(Calendar.AM_PM) == 0)
			AM_PM = "AM";
		else
			AM_PM = "PM";
		return day + "." + month + "." + year + "_" + hour + "." + minute + "." + second +  "." + AM_PM;
	}

}