AndroidJava

안드로이드(Android)(java) 현재 월의 시작일자 가져오는 방법

다음 예제코드는 시작일을 가져오는 코드입니다. 시작일은 무조건 1일 이니, 1로 세팅만 하면 됩니다.

public static String getCurrentFirstDateOfMonth(){
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, 1);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//Log.d("TAG", " : " + sdf.format(cal.getTime()));
return sdf.format(cal.getTime());
}

Leave a Reply

error: Content is protected !!