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
13,751
questions
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 ...
382
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 ...
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...
264
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....
254
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 ...
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 ...
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 ...
228
votes
3
answers
408k
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:
...
222
votes
10
answers
501k
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?
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 ...
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 ...
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])...
199
votes
8
answers
476k
views
Java: Get month Integer from Date
How do I get the month as an integer from a Date object (java.util.Date)?
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?
174
votes
28
answers
401k
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 ...
167
votes
13
answers
225k
views
How to add calendar events in Android?
I'm just getting up to speed on Android, and today in a project meeting someone said that Android has no native calendar app so users just use whatever calendar app they like.
Is this true, and if so ...
165
votes
10
answers
243k
views
How to calculate the last day of the month?
I am having issues with the calculation of when the next Last Day of the Month is for a notification which is scheduled to be sent.
Here is my code:
RecurrenceFrequency recurrenceFrequency = ...
155
votes
17
answers
248k
views
How to map month name to month number and vice versa?
I am trying to create a function that can convert a month number to an abbreviated month name or an abbreviated month name to a month number. I thought this might be a common question but I could not ...
142
votes
3
answers
230k
views
Moment.js get day name from date
I'm using jquery and moment.js for a custom calendar.
I have a date object in a variable myDate like :
Object { date="2014-12-23 14:00:00", timezone_type=3, timezone="Europe/Paris"}
I want, using ...
131
votes
6
answers
211k
views
Creating java date object from year,month,day
int day = Integer.parseInt(request.getParameter("day")); // 25
int month = Integer.parseInt(request.getParameter("month")); // 12
int year = Integer.parseInt(request.getParameter("year")); // 1988
...
129
votes
12
answers
262k
views
How do I localize the jQuery UI Datepicker?
I really need a localized dropdown calendar. An English calendar doesn't exactly communicate excellence on a Norwegian website ;-)
I have experimented with the jQuery DatePicker, their website says ...
120
votes
13
answers
265k
views
Why is the month changed to 50 after I added 10 minutes?
I have this date object:
SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd HH:mm");
Date d1 = df.parse(interviewList.get(37).getTime());
value of d1 is Fri Jan 07 17:40:00 PKT 2011
Now I am ...
119
votes
12
answers
168k
views
Month name as a string
I'm trying to return the name of the month as a String, for instance "May", "September", "November".
I tried:
int month = c.get(Calendar.MONTH);
However, this returns integers (5, 9, 11, ...
119
votes
9
answers
77k
views
Calendar returns wrong month [duplicate]
Calendar rightNow = Calendar.getInstance();
String month = String.valueOf(rightNow.get(Calendar.MONTH));
After the execution of the above snippet, month gets a value of 10 instead of 11. How come?
117
votes
7
answers
115k
views
How can I use PHP to dynamically publish an ical file to be read by Google Calendar?
Any Google search on PHP ical just brings up phpicalendar and how to parse or read IN ical files. I just want to write a PHP file that pulls events from my database and writes them out in ical format.
...
114
votes
33
answers
159k
views
Calculate business days
I need a method for adding "business days" in PHP. For example, Friday 12/5 + 3 business days = Wednesday 12/10.
At a minimum I need the code to understand weekends, but ideally it should account for ...
111
votes
22
answers
306k
views
How can I get Month Name from Calendar?
Is there a oneliner to get the name of the month when we know:
int monthNumber = calendar.get(Calendar.MONTH)
Or what is the easiest way?
111
votes
7
answers
217k
views
How do I create a link to add an entry to a calendar?
I'm working for this nightclub and are currently making a website for them, they've got lots events and their site is built a lot around events, today they make an facebook event of every event but it ...
97
votes
9
answers
238k
views
How to handle calendar TimeZones using Java?
I have a Timestamp value that comes from my application. The user can be in any given local TimeZone.
Since this date is used for a WebService that assumes the time given is always in GMT, I have a ...
93
votes
25
answers
289k
views
How to sanity check a date in Java
I find it curious that the most obvious way to create Date objects in Java has been deprecated and appears to have been "substituted" with a not so obvious to use lenient calendar.
How do you check ...