Share

Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





#Java - Code Snippets for '#Calendar.hour' - 4 code snippet(s) found

 Sample 1. Get current time using GregorianCalendar

Calendar calendar = new GregorianCalendar();
float currentTime = calendar.get( Calendar.HOUR_OF_DAY ) + ((float)calendar.get( Calendar.MINUTE )/100);

   Like      Feedback     GregorianCalendar  Calendar.HOUR_OF_DAY  Calendar.MINUTE  Calendar.java.util.Calendar


 Sample 2. Get Date and Time after few Hours

Date getDateTimeAfterNHours(int numberOfHours){
   Calendar futureTime = Calendar.getInstance();
   futureTime.setTime(new Date()); // Set Current Date
   futureTime.add(Calendar.HOUR, numberOfDays); // Add n hours to current Date and Time

   return new Date(futureTime.getTimeInMillis());
}

   Like      Feedback     date   calendar   java.util  calendar.add  calendar.hour  calendar.settime  calendar.gettimeinmillis


 Sample 3. Code Sample / Example / Snippet of java.util.Calendar

  private SparkHandlerImpl() {

classServer = new HttpServer(CLASS_DIR);



classServer.start();

System.setProperty("spark.repl.class.uri", classServer.uri());



final Calendar calendar = Calendar.getInstance();

classId = new AtomicInteger(

calendar.get(Calendar.HOUR_OF_DAY) * 10000

+ calendar.get(Calendar.MINUTE) * 100

+ calendar.get(Calendar.SECOND));

}


   Like      Feedback      java.util.Calendar


 Sample 4. Code Sample / Example / Snippet of java.util.Calendar

    private static Calendar getToday() {

Calendar cal = Calendar.getInstance();

cal.set(Calendar.HOUR_OF_DAY, 12);

cal.set(Calendar.MINUTE, 0);

cal.set(Calendar.SECOND, 0);

cal.set(Calendar.MILLISECOND, 0);

return cal;

}


   Like      Feedback      java.util.Calendar



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus