Current date in android studio

Android java set current

Calendar c = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String strDate = sdf.format(c.getTime());
Log.d("Date","DATE : " + strDate)

Android java get current

import java.time.*;
LocalDate date = LocalDate.now();
import java.time.*;
LocalDateTime datetime = LocalDateTime.now();
Content Protection by DMCA.com
Please Share