List of usage examples for java.util Calendar getInstance
public static Calendar getInstance()
From source file:co.com.runt.runistac.logica.TareasLogica.java
public static void main(String[] args) { Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_YEAR, 30); System.out.println(c); }
From source file:Text2FormatStorageMR.java
@SuppressWarnings("deprecation") public static void main(String[] args) throws Exception { if (args.length != 2) { System.out.println("FormatFileMR <input> <output>"); System.exit(-1);//ww w .ja v a 2s . c o m } JobConf conf = new JobConf(FormatStorageMR.class); conf.setJobName("Text2FormatMR"); conf.setNumMapTasks(1); conf.setNumReduceTasks(4); conf.setOutputKeyClass(LongWritable.class); conf.setOutputValueClass(Unit.Record.class); conf.setMapperClass(TextFileTestMapper.class); conf.setReducerClass(FormatFileTestReducer.class); conf.setInputFormat(TextInputFormat.class); conf.setOutputFormat(FormatStorageOutputFormat.class); conf.set("mapred.output.compress", "flase"); Head head = new Head(); initHead(head); head.toJobConf(conf); FileInputFormat.setInputPaths(conf, args[0]); Path outputPath = new Path(args[1]); FileOutputFormat.setOutputPath(conf, outputPath); FileSystem fs = outputPath.getFileSystem(conf); fs.delete(outputPath, true); JobClient jc = new JobClient(conf); RunningJob rj = null; rj = jc.submitJob(conf); String lastReport = ""; SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss,SSS"); long reportTime = System.currentTimeMillis(); long maxReportInterval = 3 * 1000; while (!rj.isComplete()) { try { Thread.sleep(1000); } catch (InterruptedException e) { } int mapProgress = Math.round(rj.mapProgress() * 100); int reduceProgress = Math.round(rj.reduceProgress() * 100); String report = " map = " + mapProgress + "%, reduce = " + reduceProgress + "%"; if (!report.equals(lastReport) || System.currentTimeMillis() >= reportTime + maxReportInterval) { String output = dateFormat.format(Calendar.getInstance().getTime()) + report; System.out.println(output); lastReport = report; reportTime = System.currentTimeMillis(); } } System.exit(0); }
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 w w w . java 2 s.c o m*/ 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 Calendar nextDayOfWeek(int dow) { Calendar date = Calendar.getInstance(); int diff = dow - date.get(Calendar.DAY_OF_WEEK); if (!(diff > 0)) { diff += 7;//from www. j ava 2 s.co m } date.add(Calendar.DAY_OF_MONTH, diff); return date; }
From source file:Main.java
public static int getYear() { return Calendar.getInstance().get(Calendar.YEAR); }
From source file:Main.java
public static int getHour() { return Calendar.getInstance().get(Calendar.HOUR_OF_DAY); }
From source file:Main.java
public static int getMonth() { return Calendar.getInstance().get(Calendar.MONTH) + 1; }
From source file:Main.java
public static int getMonth() { return Calendar.getInstance().get(Calendar.MONTH); }
From source file:Main.java
public static String getDate() { return Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + " "; }
From source file:Main.java
public static int getMinute() { return Calendar.getInstance().get(Calendar.MINUTE); }