joba joba - 4 months ago 6x
Android Question

How to use now Time in android studio

am c# developer and in c# you can use to get this time as example but in android studio i do not know how to do that can you help me please .
I need just hour and minute thanks


You could use this example to get the current date:

import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class GetCurrentDateTime {
    public static void main(String[] args) {
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        //get current date time with Date()
        Date date = new Date();

        //get current date time with Calendar()
        Calendar cal = Calendar.getInstance();

Using either Date or Calendar gives the same result in this case. But if you need to set particular dates or do date arithmetic, use a Calendar. Calendars also handle localisation.