package com.yeejoin.amos.iec104.tcp.utils;

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

public class GenerateDate {
	public static String getCP56Time2a() {
        Calendar calendar=new GregorianCalendar();
        int year = Integer.parseInt(String.valueOf(calendar.get(Calendar.YEAR)).substring(2));
        int month = calendar.get(Calendar.MONTH);
        int day = calendar.get(Calendar.DATE);
        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        int minute = calendar.get(Calendar.MINUTE);
        int second = calendar.get(Calendar.SECOND);
        int milliSecond = calendar.get(Calendar.MILLISECOND);
        int handleS = second * 1000 + milliSecond;

        String yearStr = Integer.toHexString(year);
        yearStr = yearStr.length() > 1?yearStr:"0".concat(yearStr);
        String monthStr = Integer.toHexString(month);
        monthStr = monthStr.length() > 1?monthStr:"0".concat(monthStr);
        String dayStr = Integer.toHexString(day);
        dayStr = dayStr.length() > 1?dayStr:"0".concat(dayStr);
        String hourStr = Integer.toHexString(hour);
        hourStr = hourStr.length() > 1?hourStr:"0".concat(hourStr);
        String minuteStr = Integer.toHexString(minute);
        minuteStr = minuteStr.length() > 1?minuteStr:"0".concat(minuteStr);
        String handleSStr = Integer.toHexString(handleS);

		return handleSStr + minuteStr + hourStr + dayStr + monthStr + yearStr;
	}
}
