+ 1
How to display current day and time
using functions in java
3 Respuestas
+ 1
import java.text.SimpleDateFormat;
import java.util.Date;
public class Main{
public static void main(String[] app){
SimpleDateFormat date = new SimpleDateFormat("dd/MM/yyyy mm:HH:ss a");
System.out.println(date.format(new Date()));
}
}
+ 1
You can also use the java time like this:
import java.time.LocalDateTime;
public class Program
{
public static void main(String[] args) {
LocalDateTime date= LocalDateTime.now() ;
System.out.println(date);
}
}
0
@sai reddy, this return the date and time of the server. So, for SoloLearn Playground the response for code may be different from your local date and time.