package com.huimv.local.utils;

import org.springframework.stereotype.Component;

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

@Component
public class TimeUtil {
    /**
     *
     * @return
     */
    public String getHourAndMinute(){
        GregorianCalendar calendar = new GregorianCalendar();
        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        int minute = calendar.get(Calendar.MINUTE);
        String hourStr = "";
        String minuteStr = "";
        if(hour<10){
            hourStr="0"+hour;
        }else{
            hourStr = String.valueOf(hour);
        }
        if(minute<10)
        {
            minuteStr="0"+minute;
        }else{
            minuteStr=String.valueOf(minute);
        }
        return hourStr+":"+minuteStr;
    }
}
