I'm trying to make an activity where I can select a time and date to save in a database to later use on a calendar to highlight days that are saved in the database. I looked into the DatePicker and TimePicker but unfortunately it tells me that i would need api 24 to use a lot of the functions i would need. Is there another option to select a date and time? Or are there functions i can use from the Calendar that are available for api 16?
In a few cases, there are multiple classes with the same name in the Android SDK:
java.util.Calendar vs. android.icu.util.Calendar
android.app.Fragment vs. android.support.v4.app.Fragment
java.security.cert.Certificate vs. javax.security.cert.Certificate
And so on
When adding the import statement to your project, pay close attention to which one of the duplicates that you import, so you are using the one that you expect.
In your case, you want java.util.Calendar, most likely.
Related
I am developing an Android app for an Ethiopian company and have to deal with dates.
The calendar used in Ethiopia is similar to the Gregorian one but has two main differences: it's set approx. 7 years earlier and has 13 months.
At the time I post this question the date is 13-09-2021 in the Gregorian calendar and 03-01-2014 in the Ethiopian one.
My questions are:
does Android support the Ethiopian calendar and is it customary for people in Ethiopia to have their devices use it?
if so, do I have to get the default formatter (that uses the default calendar: Calendar.getInstance()) in order to format the date properly?
instead, if the device uses the Gregorian calendar how does Java support the translation to the Ethiopian date?
What would you suggest in order to simulate the full scenario, with the device set with the proper current Ethiopian date (as if coming from the network provider) and locale?
While I know nothing about these calendaring systems, perhaps…
ThreeTen-Extra
Add the ThreeTen-Extra library to your project to access the EthiopicChronology class that plugs into the java.time framework bundled with Android.
This chronology defines the rules of the Ethiopic calendar system. This calendar system is primarily used in Ethiopia. Dates are aligned such that 0001-01-01 (Ethiopic) is 0284-08-29 (ISO).
You can also find a CopticChronology class there too.
About the calendrical background:
The Ethiopian calendar is rather a local calendar with some popularity in Ethiopia itself. And yes, there is even a special time keeping mode in this country starting the day at 6 am. However, I am not sure if the calendar is also wide-spread on mobile phones due to lack of sufficient support in the common operating systems like Android, IOS or Windows. Outside of Ethiopia, it is probably only relevant for religous minded Ethiopian people in the diaspora.
Support on Android:
You can find some support presented by the class EthiopicCalendar delivered by IBM. I strongly assume that Amharic numbers are supported (but am not completely sure). I am less confident about the support for 6 am as start of the day and counting as zero (relevant if you ask for the current date). IBM says (similar but not identical to the standard usage of Calendar.getInstance()):
EthiopicCalendar usually should be instantiated using
Calendar.getInstance(ULocale) passing in a ULocale with the tag
"#calendar=ethiopic".
The API of IBM offers a translation to the gregorian calendar and vice versa via the counted milliseconds since 1970-01-01T00:00Z. For formatting or parsing, use the dedicated formatter engine of IBM. Attention, it is not the standard formatting engine of Android. Of course, you have still to worry with strange features like counting the first month as number zero (instead of one).
Alternative library Time4A:
My library Time4A is also written for Android and is a sister project of the main lib Time4J. Both libs contain the classes EthiopianCalendar and EthiopianTime. You will find some code examples in the javadoc. Support for non-decimal Amharic numbers exists, too. These classes require a special formatting engine, too, called ChronoFormatter. Like in case of IBM, Ethiopian month names like Meskerem (even in Amharic or other languages) are well supported.
A transformation to the gregorian calendar (and vice versa) can be obtained by the expression ethiopianDate.transform(PlainDate.axis()) where the parameter denotes the target calendar (here, PlainDate is the gregorian type).
I am a beginner in Java programming and I am using Netbeans. I want to change the Date format of the Microba date picker to "dd-MMM-yy" and also remove the remaining fields. How to do these things?
Thank you.
Since Microba DataPicker is open source you could just clone the repo and have a look at the source code for your self.
If you have a look at the source code for the DatePicker class you will notice a number constructors which you can use to customise the picker, several take a DateFormat class which you can use to modify the format of the date value.
If you don't know how to use DateFormat, then I recommend you take a look at SimpleDateFormat, there are countless examples available to show you how to use it
As to remove elements, you'd have to look closer at the source code and make determinations on how best that might be achieved, since I'm not sure what fields you're talking about.
I am using android.text.format.Dateformat package. For same locale, I am getting two different date formats. For example, US - 7/21/2017 and in another device as 7/21/17. First device is with API 18 and second one is API 24.
Different JRE implementations can have variations in how classes are implemented, even across versions. Your two devices likely have small variations in the default US date format, as in 2 vs 4 digits years.
You need to provide some code and JRE details if you want further guidance.
android.text.format.Dateformat will print strings that take into account the preferences set in the user's settings app. Almost every phone will allow you to choose between 12-hour and 24-hour time (e.g. 3:00 PM vs 15:00), but some phones also allow you to choose the format you'd like to see dates in.
I suspect your first phone's setting is M/d/yyyy and your second phone's is M/d/yy.
Tapestry comes with Date picker, which is fine if you want to pick dates only.
However, I'm in need of selecting time as well (date and time filtering).
Due to specific reason, I am not allowed to use jQuery, which is unforutunate, because I've found this neat Date and Time picker: https://fgelinas.com/code/timepicker/
Is there a similar, but Prototype based Date and Time picker for Tapestry 5.3?
Take a look at Howard's tapx-datefield library. I've not used it myself but it claims to support date & time. I think it wasn't included in tapestry core because of license incompatability.
Is there away of creating a calendar app for android from scratch using java and xml in eclipse or is there an already made calendar.
A Calendar is simply a table, which you can create in Android. A TextView on top can be used for the current month. Clicking on a cell can open the list of events for that day.
Well, there are two ways to "create your own calendar".
The easy way is to create a client of google calendar or other service.
And the second is to create a client and server of your calendar.