Skip to main content

Questions tagged [calendar]

A calendar is a system of reckoning time in which the beginning, length and divisions of a year are defined. The term may refer to a software class or library for the manipulation and display of calendar data, or to a list of events with associated dates and times, managed by a human via an application or operating system user interface.

calendar
390 votes
13 answers
200k views

Java Date vs Calendar

Could someone please advise the current "best practice" around Date and Calendar types. When writing new code, is it best to always favour Calendar over Date, or are there circumstances where Date is ...
Marty Pitt's user avatar
  • 29.1k
381 votes
12 answers
186k views

Calendar Recurring/Repeating Events - Best Storage Method

I am building a custom events system, and if you have a repeating event that looks like this: Event A repeats every 4 days starting on March 3, 2011 or Event B repeats every 2 weeks on Tuesday ...
Brandon - Free Palestine's user avatar
346 votes
18 answers
202k views

Why is January month 0 in Java Calendar?

In java.util.Calendar, January is defined as month 0, not month 1. Is there any specific reason to that ? I have seen many people getting confused about that...
Stéphane Bonniez's user avatar
263 votes
8 answers
164k views

System.currentTimeMillis() vs. new Date() vs. Calendar.getInstance().getTime()

In Java, what are the performance and resource implications of using System.currentTimeMillis() vs. new Date() vs. Calendar.getInstance().getTime() As I understand it, System....
Vihung's user avatar
  • 13.3k
253 votes
17 answers
77k views

What's the best way to model recurring events in a calendar application? [closed]

I'm building a group calendar application that needs to support recurring events, but all the solutions I've come up with to handle these events seem like a hack. I can limit how far ahead one can ...
Clinton Dreisbach's user avatar
234 votes
11 answers
772k views

Calendar date to yyyy-MM-dd format in java

How to convert calendar date to yyyy-MM-dd format. Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, 1); Date date = cal.getTime(); SimpleDateFormat format1 = new ...
nr.iras.sk's user avatar
  • 8,380
233 votes
14 answers
441k views

How to get complete month name from DateTime

What is the proper way to get the complete name of month of a DateTime object? e.g. January, December. I am currently using: DateTime.Now.ToString("MMMMMMMMMMMMM"); I know it's not the correct ...
user avatar
228 votes
3 answers
407k views

Converting a Date object to a calendar object [duplicate]

So I get a date attribute from an incoming object in the form: Tue May 24 05:05:16 EDT 2011 I am writing a simple helper method to convert it to a calendar method, I was using the following code: ...
Will's user avatar
  • 8,544
222 votes
10 answers
500k views

How to subtract X day from a Date object in Java?

I want to do something like: Date date = new Date(); // current date date = date - 300; // substract 300 days from current date and I want to use this "date" How to do it?
yetAnotherSE's user avatar
  • 3,218
210 votes
9 answers
430k views

Convert String to Calendar Object in Java

I am new to Java, usually work with PHP. I am trying to convert this string: Mon Mar 14 16:02:37 GMT 2011 Into a Calendar Object so that I can easily pull the Year and Month like this: String ...
Doug Molineux's user avatar
202 votes
11 answers
310k views

How to subtract X days from a date using Java calendar?

Anyone know a simple way using Java calendar to subtract X days from a date? I have not been able to find any function which allows me to directly subtract X days from a date in Java. Can someone ...
fmsf's user avatar
  • 36.8k
199 votes
22 answers
294k views

Number of days in particular month of particular year?

How to know how many days has particular month of particular year? String date = "2010-01-19"; String[] ymd = date.split("-"); int year = Integer.parseInt(ymd[0]); int month = Integer.parseInt(ymd[1])...
Klausos Klausos's user avatar
199 votes
8 answers
475k views

Java: Get month Integer from Date

How do I get the month as an integer from a Date object (java.util.Date)?
Muhd's user avatar
  • 25.2k
185 votes
11 answers
145k views

Programmatically add custom event in the iPhone Calendar

Is there any way to add iCal event to the iPhone Calendar from the custom App?
Stream's user avatar
  • 9,473
174 votes
28 answers
400k views

How do I calculate someone's age in Java?

I want to return an age in years as an int in a Java method. What I have now is the following where getBirthDate() returns a Date object (with the birth date ;-)): public int getAge() { long ...
nojevive's user avatar
  • 3,558

15 30 50 per page
1
2 3 4 5
917