Parts of my old app are deprecated, I am trying to rebuild it. Basically it is a Calendar with month view. This is a part of my gridview adapter:
public View getView(int position, View view, ViewGroup parent) {
Date date = getItem(position);
int day = date.getDate();
int month = date.getMonth();
int year = date.getYear();
}
and the int day = date.getDate(); int month = date.getMonth(); int year = date.getYear();
are deprecated. I am trying to use the Calendar
class instead of Date
but unable to do the same. I know that for retrieve the day, month or year I can use this:
Calendar calendar = Calendar.getInstance();
calendar.get(Calendar.DAY_OF_MONTH);
but I don't know how to convert this line:
Date date = getItem(position);
for using with Calendar
.
Grid Calendar is a chart type scheduler for check of multiple schedules at a glance. For plans of private and family, for project of works, for about your favorite sports team, and so on. You can manage schedules that you want to grasp anytime.
Views in Smartsheet allow you to see and work with your data in different ways. You can choose between: Grid View—Displays data in a spreadsheet format. Gantt View—Displays data in a spreadsheet on the left and a Gantt chart on the right. Card View—Displays data in cards organized in lanes.
Anyone on a plan with the Calendar App can create and own calendars. Anyone with a Smartsheet account can access a shared calendar. A license is required to create and own a calendar.
In order to use Gantt View, you must have at least two Date columns in your sheet: a start date and an end date.
You can use this line of code:
Just replace this line
Date date = getItem(position);
with this line:
Calendar calendar = Calendar.getInstance();
Date date = calendar.getTime();
Here is a full example for you:
Calendar calendar = Calendar.getInstance();
Date date = calendar.getTime();
int day = calendar.get(Calendar.DAY_OF_MONTH);
int month = calendar.get(Calendar.MONTH);
int year = calendar.get(Calendar.YEAR);
Here is how you convert a Date
object to a Calendar
object:
Calendar cal = Calendar.getInstance();
cal.setTime(date);
Then (like you said) you can do:
int day = cal.get(Calendar.DAY_OF_MONTH);
int month = cal.get(Calendar.MONTH)
int year = cal.get(Calendar.YEAR);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With