package funcoes.util;
import java.awt.Dimension;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
public class SistemaOperacional {
public static String getNome() {
String nome = System.getProperty("os.name").toUpperCase();
if (nome.contains(" ")) {
nome = nome.substring(0, nome.indexOf(" "));
}
return nome;
}
public static String getPais() {
return System.getProperty("user.country").toUpperCase();
}
public static String getBarraDiretorios() {
String barra = "/";
if (SistemaOperacional.getNome().equals("LINUX")) {
barra = "/";
} else if ((SistemaOperacional.getNome().equals("WINDOWS"))) {
barra = "\\";
}
return barra;
}
/**
*
* @param data exemplo 01/01/01
*/
public static void mudarDataSistema(String data) {
Date newDate = new Date(data);
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
String cmd = "cmd /C date " + sdf.format(newDate);
executarComando(cmd);
}
public static void executarComando(String comando) {
try {
Process proc = Runtime.getRuntime().exec(comando);
} catch (IOException ex) {
Logger.getLogger(Windows.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static String getDiretorioAtual() {
return System.getProperty("user.dir").toUpperCase();
}
public static String getVersao() {
return System.getProperty("os.version").toUpperCase();
}
public static String getDiretorioUsuario() {
return System.getProperty("user.home").toUpperCase();
}
public static String getNomeUsuario() {
return System.getProperty("user.home").toUpperCase();
}
public static String getLinguagem() {
return System.getProperty("user.language").toUpperCase();
}
public static String getCpu() {
return System.getProperty("sun.cpu.isalist").toUpperCase();
}
/**
*
* @param hora exemplo 08:30:30
*/
public static void mudarHoraSistema(String hora) {
Date newDate = new Date("01/01/01 " + hora);
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");
String cmd = "cmd /C time " + sdf.format(newDate);
executarComando(cmd);
}
public static Dimension getResolucao() {
java.awt.Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
return toolkit.getScreenSize();
}
}
Nenhum comentário:
Postar um comentário