List of usage examples for java.util Calendar DAY_OF_MONTH
int DAY_OF_MONTH
To view the source code for java.util Calendar DAY_OF_MONTH.
Click Source Link
get
and set
indicating the day of the month. From source file:de.codesourcery.planning.DateAxisTestTool.java
public static void main(String[] args) { axis.setStartDate(DateUtils.round(new Date(), Calendar.DAY_OF_MONTH)); axis.setRange(Duration.weeks(1)); axis.setTickDuration(Duration.oneDay()); JFrame frame = new JFrame(); frame.getContentPane().add(new DateCanvas()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null);//from ww w .jav a2 s.c o m frame.pack(); frame.setVisible(true); }
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:DatePrint1.java
public static void main(String[] argv) { //+/*w w w. j a va2s . com*/ Calendar c = new GregorianCalendar(1918, 10, 11); System.out.println(c.get(Calendar.DAY_OF_MONTH) + " " + c.get(Calendar.MONTH) + ", " + c.get(Calendar.YEAR) + " " + c.get(Calendar.ERA)); //- }
From source file:DayWeek.java
public static void main(String[] av) { //+// ww w. j a v a2 s. c o m Calendar c = Calendar.getInstance(); // today System.out.println("Year: " + c.get(Calendar.YEAR)); System.out.println("Month: " + c.get(Calendar.MONTH)); System.out.println("Day: " + c.get(Calendar.DAY_OF_MONTH)); System.out.println("Day of week = " + c.get(Calendar.DAY_OF_WEEK)); System.out.println("Day of year = " + c.get(Calendar.DAY_OF_YEAR)); System.out.println("Week in Year: " + c.get(Calendar.WEEK_OF_YEAR)); System.out.println("Week in Month: " + c.get(Calendar.WEEK_OF_MONTH)); System.out.println("Day of Week in Month: " + c.get(Calendar.DAY_OF_WEEK_IN_MONTH)); System.out.println("Hour: " + c.get(Calendar.HOUR)); System.out.println("AM or PM: " + c.get(Calendar.AM_PM)); System.out.println("Hour (24-hour clock): " + c.get(Calendar.HOUR_OF_DAY)); System.out.println("Minute: " + c.get(Calendar.MINUTE)); System.out.println("Second: " + c.get(Calendar.SECOND)); //- }
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:CalcoloRitardiLotti.java
public static void main(String[] args) { String id_ref = "cbededce-269f-48d2-8c25-2359bf246f42"; String requestString = "http://dati.openexpo2015.it/catalog/api/action/datastore_search?resource_id=" + id_ref;/* w w w . j ava 2 s. c om*/ HttpClient client = HttpClientBuilder.create().build(); HttpGet request = new HttpGet(requestString); try { HttpResponse response = client.execute(request); BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); String result = ""; String resline = ""; Calendar c = Calendar.getInstance(); Date current = Date.valueOf( c.get(Calendar.YEAR) + "-" + (c.get(Calendar.MONTH) + 1) + "-" + c.get(Calendar.DAY_OF_MONTH)); while ((resline = rd.readLine()) != null) result += resline; //System.out.println(jsonObject.toString()); if (result != null) { JSONObject jsonObject = new JSONObject(result); JSONObject resultJson = (JSONObject) jsonObject.get("result"); JSONArray records = (JSONArray) resultJson.get("records"); Date temp1, temp2; //System.out.printf(records.toString()); long diffInizioFineLavori; long ritardo; long den = (24 * 60 * 60 * 1000); JSONObject temp; DefaultCategoryDataset cdata = new DefaultCategoryDataset(); String partialQuery; DefaultPieDataset data = new DefaultPieDataset(); String totalQuery = ""; int countSospesi = 0; int countConclusi = 0; int countVerifica = 0; int countInCorso = 0; int countCollaudo = 0; String stato; for (int i = 0; i < records.length(); i++) { temp = (JSONObject) records.get(i); temp1 = Date.valueOf((temp.getString("Data Consegna Lavori")).substring(0, 10)); temp2 = Date.valueOf((temp.getString("Data Fine lavori")).substring(0, 10)); diffInizioFineLavori = (long) (temp2.getTime() - temp1.getTime()) / den; stato = temp.getString("STATO"); if (stato.equals("Concluso")) countConclusi++; else if (stato.equals("In corso")) countInCorso++; else if (stato.contains("Verifiche")) countVerifica++; else if (stato.contains("Collaudo sospeso") || stato.contains("sospeso")) countSospesi++; else countCollaudo++; if (!temp.getString("STATO").equals("Concluso") && temp2.getTime() < current.getTime()) ritardo = (long) (current.getTime() - temp2.getTime()) / den; else ritardo = 0; cdata.setValue(ritardo, String.valueOf(i + 1), String.valueOf(i + 1)); System.out.println( "Opera: " + temp.getString("Oggetto del lotto") + " | id: " + temp.getInt("_id")); System.out.println("Data consegna lavoro: " + temp.getString("Data Consegna Lavori") + " | Data fine lavoro: " + temp.getString("Data Fine lavori")); System.out.println("STATO: " + temp.getString("STATO")); System.out.println("Differenza in giorni: " + diffInizioFineLavori + " | Numero giorni contrattuali: " + temp.getString("numero di giorni contrattuali")); System.out.println("Ritardo accumulato: " + ritardo); System.out.println("----------------------------------"); partialQuery = "\nid: " + temp.getInt("_id") + "\nOpera:" + temp.getString("Oggetto del lotto") + "\n" + "Data consegna lavoro: " + temp.getString("Data Consegna Lavori") + "Data fine lavoro: " + temp.getString("Data Fine lavori") + "\n" + "STATO: " + temp.getString("STATO") + "\n" + "Differenza in giorni: " + diffInizioFineLavori + " - Numero giorni contrattuali: " + temp.getString("numero di giorni contrattuali") + "\n" + "Ritardo accumulato: " + ritardo + "\n" + "----------------------------------\n"; totalQuery = totalQuery + partialQuery; } JFreeChart chart1 = ChartFactory.createBarChart3D("RITARDI AL " + current, "Id lotto", "ritardo(in giorni)", cdata); ChartRenderingInfo info = null; ChartUtilities.saveChartAsPNG( new File(System.getProperty("user.dir") + "/istogramma" + current + ".png"), chart1, 1500, 1500, info, true, 10); FileUtils.writeStringToFile(new File(current + "_1.txt"), totalQuery); data.setValue("Conclusi: " + countConclusi, countConclusi); data.setValue("Sospeso: " + countSospesi, countSospesi); data.setValue("In Corso: " + countInCorso, countInCorso); data.setValue("Verifica: " + countVerifica, countVerifica); data.setValue("Collaudo: " + countCollaudo, countCollaudo); JFreeChart chart2 = ChartFactory.createPieChart3D("Statistiche del " + current, data, true, true, true); ChartUtilities.saveChartAsPNG(new File(System.getProperty("user.dir") + "/pie" + current + ".png"), chart2, 800, 450); } } catch (Exception e) { e.printStackTrace(); } }
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 w w w .j av a 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(); } }
From source file:org.ptm.translater.App.java
public static void main(String... args) { GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ctx.load("file:src/main/resources/spring/datasource.xml"); ctx.refresh();//from ww w . j a va 2 s. com GenericXmlApplicationContext ctx2 = new GenericXmlApplicationContext(); ctx2.load("file:src/main/resources/spring/datasource2.xml"); ctx2.refresh(); ArchiveDao archiveDao = ctx.getBean("archiveDao", ArchiveDao.class); List<Archive> archives = archiveDao.findAll(); UserDao userDao = ctx2.getBean("userDao", UserDao.class); TagDao tagDao = ctx2.getBean("tagDao", TagDao.class); PhotoDao photoDao = ctx2.getBean("photoDao", PhotoDao.class); List<Tag> tagz = tagDao.findAll(); Map<String, Long> hashTags = new HashMap<String, Long>(); for (Tag tag : tagz) hashTags.put(tag.getName(), tag.getId()); MongoCache cache = new MongoCache(); Calendar calendar = Calendar.getInstance(); Map<String, String> associates = new HashMap<String, String>(); for (Archive archive : archives) { AppUser appUser = new AppUser(); appUser.setName(archive.getName()); appUser.setEmail(archive.getUid() + "@mail.th"); appUser.setPassword("123456"); Role role = new Role(); role.setRoleId("ROLE_USER"); appUser.setRole(role); userDao.save(appUser); System.out.println("\tCreate user " + appUser); for (Photo photo : archive.getPhotos()) { // ? ??? if (cache.contains(photo.getUid())) continue; System.out.println("\tNew photo"); org.ptm.translater.ch2.domain.Photo photo2 = new org.ptm.translater.ch2.domain.Photo(); photo2.setAppUser(appUser); photo2.setName(photo.getTitle()); photo2.setLicense((byte) 7); photo2.setDescription(photo.getDescription()); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { calendar.setTime(sdf.parse(photo.getTaken())); if (calendar.get(Calendar.YEAR) != 0 && calendar.get(Calendar.YEAR) > 1998) continue; photo2.setYear(calendar.get(Calendar.YEAR)); photo2.setMonth(calendar.get(Calendar.MONTH) + 1); photo2.setDay(calendar.get(Calendar.DAY_OF_MONTH)); } catch (Exception ex) { ex.printStackTrace(); } if (photo.getLongitude() != null && photo.getLongitude().length() > 0) { // String key = photo.getLongitude()+"#"+photo.getLatitude(); photo2.setLatitude(photo.getLatitude()); photo2.setLongitude(photo.getLongitude()); // if (associates.containsKey(key)) { // photo2.setAddress(associates.get(key)); // } else { // Geocoder geocoder = new Geocoder(); // GeocoderRequestBuilder geocoderRequest = new GeocoderRequestBuilder(); // GeocoderRequest request = // geocoderRequest.setLocation(new LatLng(photo.getLongitude(), photo.getLatitude())).getGeocoderRequest(); // // GeocodeResponse response = geocoder.geocode(request); // if (response.getResults().size() > 0) { // photo2.setAddress(response.getResults().get(0).getFormattedAddress()); // } // try { Thread.sleep(2000); } catch (InterruptedException ex) { ex.printStackTrace(); } // } } System.out.println("\tFind tags"); Set<Tag> tags = new HashSet<Tag>(); for (org.ptm.translater.ch1.domain.Tag tag : photo.getTags()) { Tag item = new Tag(); item.setName(tag.getName()); if (hashTags.containsKey(tag.getName())) { item.setId(hashTags.get(tag.getName())); } else { tagDao.save(item); hashTags.put(item.getName(), item.getId()); } System.out.println("\t\tinit tag " + tag.getName()); tags.add(item); } photo2.setTags(tags); System.out.println("\tFind " + tags.size() + " tags"); photoDao.save(photo2); System.out.println("\tSave photo"); Imaginator img = new Imaginator(); img.setFolder(photo2.getId().toString()); img.setPath(); for (PhotoSize ps : photo.getSizes()) { if (ps.getLabel().equals("Original")) { img.setImage(ps.getSource()); break; } } img.generate(); System.out.println("\tGenerate image of photo"); img = null; cache.create(photo.getUid()); cache.create(photo2); System.out.println("Generate: " + photo2); } } }
From source file:de.codesourcery.eve.skills.ui.utils.CalendarWidget.java
public static void main(String[] args) throws Exception { final SimpleDateFormat DF = new SimpleDateFormat("dd.MM"); final Calendar specialDate = Calendar.getInstance(); specialDate.add(Calendar.DAY_OF_MONTH, 5); final AtomicBoolean doStuff = new AtomicBoolean(false); final ICalendarRenderer renderer = new ICalendarRenderer() { @Override/*from ww w. j a v a 2s.com*/ public String getDateLabel(Date date) { return DF.format(date); } @Override public String getText(Date date) { if (DateUtils.isSameDay(date, specialDate.getTime()) && doStuff.get()) { return "SPECIAL !!!"; } return "some\nmultiline\ntext"; } @Override public String getToolTip(Date date) { return getText(date); } @Override public Color getTextColor(Date date) { return Color.RED; } }; final JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new GridBagLayout()); final CalendarWidget widget = new CalendarWidget(new Date(), renderer); widget.addSelectionListener(new ISelectionListener<Date>() { @Override public void selectionChanged(Date selected) { System.out.println("Selected date > " + selected); } }); frame.getContentPane().add(widget, new ConstraintsBuilder().end()); frame.pack(); frame.setVisible(true); java.lang.Thread.sleep(2 * 1000); doStuff.set(true); widget.refreshDateLabel(specialDate.getTime()); }
From source file:Main.java
public static int getDay(Calendar c) { return c.get(Calendar.DAY_OF_MONTH); }