import java.net.*;
import java.util.Date;
import java.text.SimpleDateFormat;
/**
*
* @author Fandi
*/
public class Coba1
{
public static void main(String[] args)
{
try{
InetAddress IP = InetAddress.getByName("localhost");
System.out.println("IP Address : " +IP.getHostAddress());
//System.out.println(IP.getHostName());
}
catch(UnknownHostException e){
System.out.println(e);
}
//Format Tanggal
Date date = new Date();
SimpleDateFormat tanggal = new SimpleDateFormat("dd");
System.out.println("Tanggal : " +tanggal.format(date));
SimpleDateFormat tanggal1 = new SimpleDateFormat("MM");
System.out.println("Bulan : " +tanggal1.format(date));
SimpleDateFormat tanggal2 = new SimpleDateFormat("yyyy");
System.out.println("Tahun : " +tanggal2.format(date));
}
}
Tidak ada komentar:
Posting Komentar