List of usage examples for java.util Date Date
@Deprecated public Date(int year, int month, int date)
From source file:Main.java
public static void main(String[] args) { Date date1 = new Date(2009, 01, 10); Date date2 = new Date(2015, 07, 01); Calendar calendar1 = Calendar.getInstance(); Calendar calendar2 = Calendar.getInstance(); calendar1.setTime(date1);/* ww w .jav a2 s . c o m*/ calendar2.setTime(date2); long milliseconds1 = calendar1.getTimeInMillis(); long milliseconds2 = calendar2.getTimeInMillis(); long diff = milliseconds2 - milliseconds1; long diffSeconds = diff / 1000; long diffMinutes = diff / (60 * 1000); long diffHours = diff / (60 * 60 * 1000); long diffDays = diff / (24 * 60 * 60 * 1000); System.out.println("\nThe Date Different Example"); System.out.println("Time in milliseconds: " + diff + " milliseconds."); System.out.println("Time in seconds: " + diffSeconds + " seconds."); System.out.println("Time in minutes: " + diffMinutes + " minutes."); System.out.println("Time in hours: " + diffHours + " hours."); System.out.println("Time in days: " + diffDays + " days."); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { SimpleDateFormat xmlDateFormat = new SimpleDateFormat("MM.dd.yy"); MapVariableResolver resolver = new MapVariableResolver(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = dbf.newDocumentBuilder(); Document document = builder.parse(new File("t.xml")); XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); xPath.setXPathVariableResolver(resolver); XPathExpression expression = xPath.compile("/schedule/show[@date=$date]/guest"); String formattedDate = xmlDateFormat.format(new Date(2006, 5, 14)); resolver.addVariable(null, "date", formattedDate); Element guest = (Element) expression.evaluate(document, XPathConstants.NODE); System.out.println(guest.getElementsByTagName("name").item(0).getTextContent()); }
From source file:edu.eci.cosw.samples.logic.Main.java
public static void main(String[] args) { ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml"); ServiceFacade sf = ac.getBean(ServiceFacade.class); List<Cliente> clientes = null; try {// w w w . jav a 2s. com clientes = sf.clientesReportadosPorApellido("var"); } catch (ClientEvaluationException ex) { System.out.println("Fallo consulta por apellido"); Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } if (clientes != null) { for (Cliente c : clientes) { System.out.println( c.getIdcliente() + " " + c.getNombre() + " " + c.getDireccion() + " " + c.getTelefono()); } } try { //Registrar un nuevo cliente sf.registrarCliente(1072672, "Guillermo Alvarez", "Calle 3#3E-116", "1234567"); } catch (ClientEvaluationException ex) { System.out.println("Fallo insercion"); Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } //Crear un pedido Date d = new Date(2015 - 1900, 8, 23); int[] idProductos = { 1 }; int[] cantidades = { 3 }; sf.registrarPedido(1072672, idProductos, cantidades, d); //Mirar en la base de datos que se creo el pedido de este cliente try { //Consulta Fallida sf.registrarCliente(333, "Luis Alvarez", "Calle 3E#3-116", "1234567"); } catch (ClientEvaluationException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } }