List of usage examples for java.util Calendar getTime
public final Date getTime()
Date
object representing this Calendar
's time value (millisecond offset from the Epoch"). From source file:javasnack.cli.CliDbUnitCsvExportDemo.java
public static void main(String[] args) throws Exception { String driver = System.getProperty("CliDbUnitCsvExportDemo.driver", "org.h2.Driver"); Class.forName(driver);/*from w w w . ja v a 2 s.co m*/ String url = System.getProperty("CliDbUnitCsvExportDemo.url", "jdbc:h2:mem:CliDbUnitCsvExportDemo"); String dbUser = System.getProperty("CliDbUnitCsvExportDemo.dbUser", "sa"); String dbPassword = System.getProperty("CliDbUnitCsvExportDemo.dbPassword", ""); Connection conn = DriverManager.getConnection(url, dbUser, dbPassword); CliDbUnitCsvExportDemo demo = new CliDbUnitCsvExportDemo(); demo.setup(conn); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); Calendar c = Calendar.getInstance(); File outDir = new File(sdf1.format(c.getTime())); outDir.mkdir(); IDatabaseConnection dbunit_conn = new DatabaseConnection(conn); IDataSet dataSet = dbunit_conn.createDataSet(); CsvBase64BinarySafeDataSetWriter.write(dataSet, outDir); conn.close(); }
From source file:Main.java
public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); int lastDate = calendar.getActualMaximum(Calendar.DATE); calendar.set(Calendar.DATE, lastDate); int lastDay = calendar.get(Calendar.DAY_OF_WEEK); System.out.println("Last Date: " + calendar.getTime()); System.out.println("Last Day : " + lastDay); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { X509CertSelector selec = new X509CertSelector(); CertificateFactory cf = CertificateFactory.getInstance("X.509"); FileInputStream in = new FileInputStream(args[0]); Certificate c = cf.generateCertificate(in); System.out.println(selec.match(c)); selec.setIssuer("CN=Peter,OU=Network Center," + "O=University,L=ZB,ST=Vancouver,C=CN"); System.out.println(selec.match(c)); Calendar cld = Calendar.getInstance(); int year = Integer.parseInt(args[1]); int month = Integer.parseInt(args[2]) - 1; int day = Integer.parseInt(args[3]); cld.set(year, month, day);/* w w w . j a v a2s .co m*/ Date d = cld.getTime(); selec.setCertificateValid(d); System.out.println(selec.match(c)); BigInteger sn = new BigInteger("1039056963"); selec.setSerialNumber(sn); System.out.println(selec.match(c)); }
From source file:com.mozilla.bagheera.util.IdUtil.java
public static void main(String[] args) throws IOException { String id = "06b87727-2946-4b1e-b654-8bafb60bb995"; long timestamp = 1360493115891L; Calendar cal = Calendar.getInstance(); //cal.set(2013, Calendar.FEBRUARY, 10); cal.setTimeInMillis(timestamp);/*from w w w . j av a 2s. c om*/ System.out.println(IdUtil.hbaseShellId(id, cal.getTime())); }
From source file:Main.java
public static void main(String[] args) { Date myDate;/*from w w w . jav a2 s.c om*/ Calendar cal = Calendar.getInstance(); cal.set(Calendar.MONTH, 9); cal.set(Calendar.DATE, 24); cal.set(Calendar.YEAR, 2013); cal.set(Calendar.HOUR, 13); cal.set(Calendar.MINUTE, 45); cal.set(Calendar.SECOND, 52); myDate = cal.getTime(); System.out.println(myDate); }
From source file:Main.java
public static void main(String[] args) { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:00Z"); Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, 2015); cal.set(Calendar.MONTH, Calendar.SEPTEMBER); cal.set(Calendar.DATE, 1);/* w w w . j av a 2 s .c om*/ cal.set(Calendar.HOUR_OF_DAY, 12); cal.set(Calendar.MINUTE, 15); Date date = cal.getTime(); System.out.println(date); TimeZone tz = TimeZone.getTimeZone("IST"); dateFormat.setTimeZone(tz); String actual = dateFormat.format(date); System.out.println(actual); }
From source file:com.discursive.jccook.lang.builders.customized.PoliticalCandidate.java
public static void main(String[] args) { // Create a State State va = new State("VA", "Virginia"); // Create a Birth Date Calendar calendar = new GregorianCalendar(); calendar.set(Calendar.YEAR, 1743); calendar.set(Calendar.MONTH, Calendar.APRIL); calendar.set(Calendar.DAY_OF_MONTH, 13); Date dob = calendar.getTime(); BigDecimal moneyRaised = new BigDecimal(293829292.93); // Create a Political Candidate PoliticalCandidate candidate = new PoliticalCandidate("Jefferson", "Thomas", dob, moneyRaised, va); System.out.println(candidate); }
From source file:com.discursive.jccook.lang.builders.reflect.PoliticalCandidate.java
public static void main(String[] args) { // START lang-ex-sample-1 // Create a State State va = new State("VA", "Virginia"); // Create a Birth Date Calendar calendar = new GregorianCalendar(); calendar.set(Calendar.YEAR, 1743); calendar.set(Calendar.MONTH, Calendar.APRIL); calendar.set(Calendar.DAY_OF_MONTH, 13); Date dob = calendar.getTime(); BigDecimal moneyRaised = new BigDecimal(293829292.93); // Create a Political Candidate PoliticalCandidate candidate = new PoliticalCandidate("Jefferson", "Thomas", dob, moneyRaised, va); System.out.println(candidate); // END lang-ex-sample-1 }
From source file:MainClass.java
public static void main(String[] args) { JFrame frame = new JFrame(); Calendar now = Calendar.getInstance(); Calendar earliest = (Calendar) now.clone(); earliest.add(Calendar.MONTH, -6); Calendar latest = (Calendar) now.clone(); latest.add(Calendar.MONTH, 6); SpinnerModel model = new SpinnerDateModel(now.getTime(), earliest.getTime(), latest.getTime(), Calendar.WEEK_OF_YEAR); final JSpinner spinner = new JSpinner(model); model.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { System.out.println(((SpinnerDateModel) e.getSource()).getDate()); }/*from w ww . ja va 2 s .c o m*/ }); frame.getContentPane().add("North", new JLabel("Choose a week")); frame.getContentPane().add("Center", spinner); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:fr.itinerennes.bundler.integration.onebusaway.GenerateStaticObaApiResults.java
public static void main(String[] args) throws IOException, GtfsException { final String url = args[0]; final String key = args[1]; final String gtfsFile = args[2]; final String out = args[3].replaceAll("/$", ""); final Map<String, String> agencyMapping = new HashMap<String, String>(); agencyMapping.put("1", "2"); final GtfsDao gtfs = GtfsUtils.load(new File(gtfsFile), agencyMapping); oba = new JsonOneBusAwayClient(new DefaultHttpClient(), url, key); gson = OneBusAwayGsonFactory.newInstance(true); final Calendar end = Calendar.getInstance(); end.set(2013, 11, 22, 0, 0);//from www . j a va 2s .c o m final Calendar start = Calendar.getInstance(); start.set(2013, 10, 4, 0, 0); final Calendar current = Calendar.getInstance(); current.setTime(start.getTime()); while (current.before(end) || current.equals(end)) { System.out.println(current.getTime()); for (final Stop stop : gtfs.getAllStops()) { final String stopId = stop.getId().toString(); final String dateDir = String.format("%04d/%02d/%02d", current.get(Calendar.YEAR), current.get(Calendar.MONTH) + 1, current.get(Calendar.DAY_OF_MONTH)); final String methodDir = String.format("%s/schedule-for-stop", out); final File outDir = new File(String.format("%s/%s", methodDir, dateDir)); outDir.mkdirs(); final File f = new File(outDir, String.format("%s.json", stopId)); final StopSchedule ss = oba.getScheduleForStop(stopId, current.getTime()); final String json = gson.toJson(ss); final Writer w = new PrintWriter(f); w.write(json); w.close(); } current.add(Calendar.DAY_OF_MONTH, 1); } final File outDir = new File(String.format("%s/trip-details", out)); outDir.mkdirs(); for (final Trip trip : gtfs.getAllTrips()) { final String tripId = trip.getId().toString(); final File f = new File(outDir, String.format("%s.json", tripId)); final TripSchedule ts = oba.getTripDetails(tripId); final String json = gson.toJson(ts); final Writer w = new PrintWriter(f); w.write(json); w.close(); } }