This question already has answers here:
How to convert time stamp string from 24 hr format to 12 hr format in dart?
(12 answers)
Closed 6 hours ago.
I am using API for getting time but the time is coming in 24hr. I want to convert to 12hr.
Need a code example for this
You can use DateFormat(from package:intl/intl.dart) to display in 12hr format.
DateFormat('h:mm a').format(DateTime.now());
Related
sorry I don't have experience with Android. I have been using an app to record IMU data and I need timestamps since epoch in nanoseconds. The app generates cvs file that states
Timestamp[nanosec]
379575046451850
379575051336382 ...
However, I always have been familiar with the timestamp like this
timestamp
1602663595777087900
1602663595795272900
Both should be in nanoseconds. I am curious because two independent apps that record data generate timestamp in ns in the same format. How should I interpret the above data?
Assuming the current epoch time is 1604009999 (10 digits), these might be microseconds (1/1,000,000 second): 379575046451850, 379575051336382 (39 years ago). And these are nanoseconds (1 billionth of a second): 1602663595777087900, 1602663595795272900 (16 days ago). Wouldn't be too sure about the format starting with 3795750, maybe one can interpret them differently. The question doesn't tell what they're supposed to mean and there was no Android 39 years ago. Maybe it's an Excel timestamp?
This question already has answers here:
System.currentTimeMillis() vs. new Date() vs. Calendar.getInstance().getTime()
(8 answers)
Closed 3 years ago.
I searched a lot I found some solutions for that and got confused to select which method to use to get a timestamp in android and which one is the best.
found
Get by using the android Calendar
Calendar.getInstance().getTimeInMillis()
By using the Date
new Date().getTime()
By using System
Long tsLong = System.currentTimeMillis()/1000;
String ts = tsLong.toString();
Please help me to understand.
System.currentTimeMillis() is obviously the most efficient since it does not even create an object, but new Date() is really just a thin wrapper about a long, so it is not far behind. Calendar, on the other hand, is relatively slow and very complex, since it has to deal with the considerable complexity and all the oddities that are inherent to dates and times (leap years, daylight savings, timezones, etc.).
It's generally a good idea to deal only with long timestamps or Date objects within your application, and only use Calendar when you actually need to perform date/time calculations or to format dates for displaying them to the user. If you have to do a lot of this, using Joda Time is probably a good idea, for the cleaner interface and better performance.
for full discussion please check the link
This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 6 years ago.
I'm building a chat application in which I'll be using emoticons, so the problem is that when I enter and send the text, for eg. -
"Hahha this is so funny 😂"
In MySQL, it gets saved as "Hahha this is so funny ??"
Can anyone tell me how to detect whether the string being saved to server contains an emoji and if it does, then accordingly convert the emoji part to special unicode format?
Thanks a ton!
Use a library like this to decode the text first.
I have't tried it myself but from what I see, it is possible.
https://android-arsenal.com/details/1/1806
This question already has answers here:
What to do when you need to store a (very) large number?
(4 answers)
Java equivalent of unsigned long long?
(10 answers)
Closed 7 years ago.
I wan to create a funny incremental game in java but I don't know how to store data. I thought use a long but I'm not sure that it will be enough.
I know that big integer could works but I'm not sure thaht it's really efficient.
You might want to use long or BigInteger class, depending on how big number you want.
Check out this question/answer for a valid solution!
What to do when you need to store a (very) large number?
This question already has answers here:
Android Convert Unix Time to GMT time
(2 answers)
Closed 9 years ago.
I am developing a Facebook app. I fetch update_time and it is like this:
updated_time":1375486365
How can I convert this into a normal time in Android?
The time you get is epoch time.
Check this http://www.epochconverter.com/
You will have to use this http://developer.android.com/reference/java/util/Date.html#Date(long)
and pass the epoch time in millis. In your case multiply by 1000.