import javautilCalendar;
import javautilTimeZone;
public void getNowTime(){
TimeZone timeZone = TimeZonegetDefault();// 获取时区 设置默认
Calendar calendar = CalendargetInstance(timeZone);//创建Calendar
Systemoutprintln("年"+calendarget(CalendarYEAR));
Systemoutprintln("月"+(calendarget(CalendarMONTH)+1));
Systemoutprintln("日"+calendarget(CalendarDATE));
Systemoutprintln("时"+calendarget(CalendarHOUR_OF_DAY)
Systemoutprintln("分"+calendarget(CalendarMINUTE));
Systemoutprintln("秒"+calendarget(CalendarSECOND));
}
//获取ip地址
public String getLocalIpAddress()
{
try {
String ipv4;
ArrayList<NetworkInterface> nilist = Collectionslist(NetworkInterfacegetNetworkInterfaces());
for (NetworkInterface ni: nilist)
{
ArrayList<InetAddress> ialist = Collectionslist(nigetInetAddresses());
for (InetAddress address: ialist)
{
if (!addressisLoopbackAddress() && InetAddressUtilsisIPv4Address(ipv4=addressgetHostAddress()))
{
return ipv4;
}
}
}
} catch (SocketException ex)
{
//Loge(LOG_TAG, extoString());
}
return null;
}
以上就是关于javame 怎么获取手机时间全部的内容,包括:javame 怎么获取手机时间、求java获取手机ip或者平板ip的代码、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)