List of usage examples for java.sql Time Time
public Time(long time)
Time
object using a milliseconds time value. From source file:CampusSmartCafe.view.MainFrame2.java
private void Ramen_orderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Ramen_orderActionPerformed // TODO add your handling code here: int[] quantity = new int[6]; if (Ramen_q0.getText().trim().length() != 0) { quantity[0] = Integer.parseInt(Ramen_q0.getText().trim()); }//from w w w .j a v a 2 s . com if (Ramen_q1.getText().trim().length() != 0) { quantity[1] = Integer.parseInt(Ramen_q1.getText().trim()); } if (Ramen_q2.getText().trim().length() != 0) { quantity[2] = Integer.parseInt(Ramen_q2.getText().trim()); } if (Ramen_q3.getText().trim().length() != 0) { quantity[3] = Integer.parseInt(Ramen_q3.getText().trim()); } if (Ramen_q4.getText().trim().length() != 0) { quantity[4] = Integer.parseInt(Ramen_q4.getText().trim()); } if (Ramen_q5.getText().trim().length() != 0) { quantity[5] = Integer.parseInt(Ramen_q5.getText().trim()); } float[] prices = { 9.25f, 8.75f, 8.75f, 4.75f, 8.75f, 4.25f }; int[] calories = { 390, 390, 390, 395, 250, 140 }; float total_f = 0; int total_c = 0; for (int i = 0; i < 6; i++) { total_f += quantity[i] * prices[i]; total_c += quantity[i] * calories[i]; } if (total_c > acc.getDietaryProf().getLeftCalorie()) { JOptionPane.showMessageDialog(null, "You don't have enough Calorie today,\nTry tomorrow :)"); } else if (total_f > acc.getExpenseProf().getLeftFunds()) { JOptionPane.showMessageDialog(null, "You don't have enough money :("); } else { AccountDAO.updateLeft(acc, total_f, total_c); JOptionPane.showMessageDialog(null, "You food will be ready at " + (new Time(System.currentTimeMillis() + 20 * 60 * 1000).toString()) + "\nCafe address is:\n" + "3540 Homestead Rd\n" + "Santa Clara, CA 95051"); Ramen_q0.setText(" "); Ramen_q1.setText(" "); Ramen_q2.setText(" "); Ramen_q3.setText(" "); Ramen_q4.setText(" "); Ramen_q5.setText(" "); Ramen_totalfunds.setText(" "); Ramen_totalcalories.setText(" "); } }
From source file:com.facebook.presto.tests.AbstractTestQueries.java
@Test public void testTimeLiterals() throws Exception { MaterializedResult.Builder builder = resultBuilder(getSession(), DATE, TIME, TIME_WITH_TIME_ZONE, TIMESTAMP, TIMESTAMP_WITH_TIME_ZONE);/* w w w .ja v a2 s . co m*/ DateTimeZone sessionTimeZone = DateTimeZoneIndex.getDateTimeZone(getSession().getTimeZoneKey()); DateTimeZone utcPlus6 = DateTimeZoneIndex.getDateTimeZone(TimeZoneKey.getTimeZoneKeyForOffset(6 * 60)); builder.row(new Date(new DateTime(2013, 3, 22, 0, 0, sessionTimeZone).getMillis()), new Time(new DateTime(1970, 1, 1, 3, 4, 5, sessionTimeZone).getMillisOfDay()), new Time(new DateTime(1970, 1, 1, 3, 4, 5, utcPlus6).getMillis()), // hack because java.sql.Time compares based on actual number of ms since epoch instead of ms since midnight new Timestamp(new DateTime(1960, 1, 22, 3, 4, 5, sessionTimeZone).getMillis()), new Timestamp(new DateTime(1960, 1, 22, 3, 4, 5, utcPlus6).getMillis())); MaterializedResult actual = computeActual( "SELECT DATE '2013-03-22', TIME '3:04:05', TIME '3:04:05 +06:00', TIMESTAMP '1960-01-22 3:04:05', TIMESTAMP '1960-01-22 3:04:05 +06:00'"); assertEquals(actual, builder.build()); }
From source file:CampusSmartCafe.view.MainFrame2.java
private void IO_order1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_IO_order1ActionPerformed // JOptionPane.showMessageDialog(null, "You food will be ready at"+"Cafe address is"); // TODO add your handling code here: int[] quantity = new int[6]; if (Togo_q0.getText().trim().length() != 0) { quantity[0] = Integer.parseInt(Togo_q0.getText().trim()); }/* w w w . jav a 2s. co m*/ if (Togo_q1.getText().trim().length() != 0) { quantity[1] = Integer.parseInt(Togo_q1.getText().trim()); } if (Togo_q2.getText().trim().length() != 0) { quantity[2] = Integer.parseInt(Togo_q2.getText().trim()); } if (Togo_q3.getText().trim().length() != 0) { quantity[3] = Integer.parseInt(Togo_q3.getText().trim()); } if (Togo_q4.getText().trim().length() != 0) { quantity[4] = Integer.parseInt(Togo_q4.getText().trim()); } if (Togo_q5.getText().trim().length() != 0) { quantity[5] = Integer.parseInt(Togo_q5.getText().trim()); } float[] prices = { 6.25f, 6.75f, 6.75f, 6.25f, 5.75f, 6.75f }; int[] calories = { 520, 520, 580, 780, 540, 690 }; float total_f = 0; int total_c = 0; for (int i = 0; i < 6; i++) { total_f += quantity[i] * prices[i]; total_c += quantity[i] * calories[i]; } if (total_c > acc.getDietaryProf().getLeftCalorie()) { JOptionPane.showMessageDialog(null, "You don't have enough Calorie today,\nTry tomorrow :)"); } else if (total_f > acc.getExpenseProf().getLeftFunds()) { JOptionPane.showMessageDialog(null, "You don't have enough money :("); } else { AccountDAO.updateLeft(acc, total_f, total_c); JOptionPane.showMessageDialog(null, "You food will be ready at " + (new Time(System.currentTimeMillis() + 12 * 60 * 1000).toString()) + "\nCafe address is:\n" + "32211 N 1st St\n" + "San Jose, CA 95131"); Togo_q0.setText(" "); Togo_q1.setText(" "); Togo_q2.setText(" "); Togo_q3.setText(" "); Togo_q4.setText(" "); Togo_q5.setText(" "); Togo_total_f.setText(" "); Togo_total_c.setText(" "); } }
From source file:CampusSmartCafe.view.MainFrame2.java
private void pizza_orderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pizza_orderActionPerformed // JOptionPane.showMessageDialog(null, "You food will be ready at"+"Cafe address is"); int[] quantity = new int[6]; if (pizza_q0.getText().trim().length() != 0) { quantity[0] = Integer.parseInt(pizza_q0.getText().trim()); }/* www. j a va2 s.com*/ if (pizza_q1.getText().trim().length() != 0) { quantity[1] = Integer.parseInt(pizza_q1.getText().trim()); } if (pizza_q2.getText().trim().length() != 0) { quantity[2] = Integer.parseInt(pizza_q2.getText().trim()); } if (pizza_q3.getText().trim().length() != 0) { quantity[3] = Integer.parseInt(pizza_q3.getText().trim()); } if (pizza_q4.getText().trim().length() != 0) { quantity[4] = Integer.parseInt(pizza_q4.getText().trim()); } if (pizza_q5.getText().trim().length() != 0) { quantity[5] = Integer.parseInt(pizza_q5.getText().trim()); } float[] prices = { 22.5f, 25.5f, 29.5f, 31.5f, 28.5f, 1.75f }; int[] calories = { 1140, 1800, 2100, 2050, 1950, 140 }; float total_f = 0; int total_c = 0; for (int i = 0; i < 6; i++) { total_f += quantity[i] * prices[i]; total_c += quantity[i] * calories[i]; } if (total_c > acc.getDietaryProf().getLeftCalorie()) { JOptionPane.showMessageDialog(null, "You don't have enough Calorie today,\nTry tomorrow :)"); } else if (total_f > acc.getExpenseProf().getLeftFunds()) { JOptionPane.showMessageDialog(null, "You don't have enough money :("); } else { AccountDAO.updateLeft(acc, total_f, total_c); JOptionPane.showMessageDialog(null, "You food will be ready at " + (new Time(System.currentTimeMillis() + 15 * 60 * 1000).toString()) + "\nCafe address is:\n" + "117 E San Carlos St\n" + "San Jose, CA"); pizza_q0.setText(" "); pizza_q1.setText(" "); pizza_q2.setText(" "); pizza_q3.setText(" "); pizza_q4.setText(" "); pizza_q5.setText(" "); pizza_total_f.setText(" "); pizza_total_c.setText(" "); } }
From source file:CampusSmartCafe.view.MainFrame2.java
private void orderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_orderActionPerformed // JOptionPane.showMessageDialog(null, "You food will be ready at"+"Cafe address is"); // TODO add your handling code here: int[] quantity = new int[6]; if (CC_q0.getText().trim().length() != 0) { quantity[0] = Integer.parseInt(CC_q0.getText().trim()); }/*from www . j ava 2s . c o m*/ if (CC_q1.getText().trim().length() != 0) { quantity[1] = Integer.parseInt(CC_q1.getText().trim()); } if (CC_q2.getText().trim().length() != 0) { quantity[2] = Integer.parseInt(CC_q2.getText().trim()); } if (CC_q3.getText().trim().length() != 0) { quantity[3] = Integer.parseInt(CC_q3.getText().trim()); } if (CC_q4.getText().trim().length() != 0) { quantity[4] = Integer.parseInt(CC_q4.getText().trim()); } if (CC_q5.getText().trim().length() != 0) { quantity[5] = Integer.parseInt(CC_q5.getText().trim()); } float[] prices = { 11.75f, 11.75f, 11.75f, 12.75f, 6.75f, 3.75f }; int[] calories = { 1360, 1740, 1540, 2130, 300, 160 }; float total_f = 0; int total_c = 0; for (int i = 0; i < 6; i++) { total_f += quantity[i] * prices[i]; total_c += quantity[i] * calories[i]; } if (total_c > acc.getDietaryProf().getLeftCalorie()) { JOptionPane.showMessageDialog(null, "You don't have enough Calorie today,\nTry tomorrow :)"); } else if (total_f > acc.getExpenseProf().getLeftFunds()) { JOptionPane.showMessageDialog(null, "You don't have enough money :("); } else { AccountDAO.updateLeft(acc, total_f, total_c); JOptionPane.showMessageDialog(null, "You food will be ready at " + (new Time(System.currentTimeMillis() + 25 * 60 * 1000).toString()) + "\nCafe address is:\n" + "3041 Stevens Creek Blvd\n" + "Santa Clara, CA 95050"); CC_q0.setText(" "); CC_q1.setText(" "); CC_q2.setText(" "); CC_q3.setText(" "); CC_q4.setText(" "); CC_q5.setText(" "); CC_total_f.setText(" "); CC_total_c.setText(" "); } }