How to convert Timezones in Double? [closed] - android

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
Can anyone tell me how to get Timezones in double, actually I get timezone like this way UTC+5.30. But I want only 5.30 in double.

try
TimeZone tz = TimeZone.getDefault();
String gmt = TimeZone.getTimeZone(tz.getID()).getDisplayName(false,
TimeZone.SHORT);
String z1 = gmt.substring(4);
String z = z1.replaceAll(":", ".");
double zo = Double.parseDouble(z);
Log.d("double time", "" + zo);

Related

Why the .whereEqualTo isn't working? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
Why this working
Query firstQuery1 = firebaseFirestore.collection("Test").whereEqualTo("test", "1");
And this isn't working
Query firstQuery1 = firebaseFirestore.collection("Test");
firstQuery1.whereEqualTo("test", "1");
firestore.collection("Test") returns an object of type CollectionReference while ref.whereEqualTo(..) returns a Query
So instead of
Query firstQuery1 = firestore.collection("Test");
firstQuery1.whereEqualTo("test", "1");
it needs to be
CollectionReference ref = firestore.collection("Test");
Query query = ref.whereEqualTo("test","1");

Why I am not getting the correct output for array.set? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
Firstly, I am storing the data in ArrayList.Now based on my index(current position) I want to replace that data with new data,but what I am getting is
old data,old data,old data,true,true,new data,new data....
Any suggestions
ArrayList<String> arr = new ArrayList<String>();
if (arr.isEmpty()) {
for(int i = 0;i<=mcq.size();i++) {
arr.add(s);
}
} else {
arr.set(currentPosition, String.valueOf(arr.add(s)));
}
"s" is a String value I am getting from somewhere else.
This looks really weird:
arr.set(currentPosition, String.valueOf(arr.add(s)));
ArrayList.set changes the elements stored at currentPosition. You want it to change it to the string value of what arr.add returns.
ArrayList.add returns a boolean, so there you get your true values from.
I think you want to do arr.set(currentPosition, s);

How to sort a string in Android [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a string like "RSEBAK" and I'd like to sort that string to "ABEKRS"
Is it possible in android?
If it is, then please guide me through.
Your spec is a bit fuzzy, but I think you mean to sort the charters in a string? If so…
String s1 = "RSEBAK";
char[] arrC = s1.toCharArray();
Arrays.sort(arrC);
String strSorted = new String(arrC);
strSorted should have "ABEKRS"

adding string as integer [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
in my application i have got 0.00 in edit text.next when i enter 2or3 or any digit its getting concat with 0.00 and getting 0.003.
if(item.equals("0.00")){
item=item+string;}
i changed the code.but this time too its getting an error
if(item.equals("0.00")){
int a=Integer.parseInt(item.toString());
int b=Integer.parseInt(string.toString());
int c=a+b;
item=String.valueOf(c);}
If you are using decimal places then you will want to use a data type that supports those, such as double. Try this:
double d = Double.parseDouble(item.toString());
NOTE: If both your variables are of string type, then you won't need to use toString()
You want O.OO but still using Integer. Try using FLOAT.
Also, FLOAT is NEVER a perfect value. So you might have .XX added.
You have an error, because "0.00" has decimal places, so it is parsed as a floating point number, not integer.
Parse it as a double:
String item = "0.00";
double result = Double.parseDouble(item) + 0.03; // result is 0.03

Regular Expression in numbers and string length Android [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to point out the users that a number can only start from 9 and and its length is to be exactly equal to 10 digits. How do I manipulate this with a regex ? Please don't mind the question, I am relatively new.
To validate that the input is exactly 10 digits, starting with 9, use:
/^9\d{9}$/
The ^9 part matches a starting 9, {d}9 matches 9 digits
Here you are. A simple solution (not with regex):
String number = "12345";
...
if (number.length() != 10 || number.startsWith("9") == false)
{
Toast.makeText(getApplicationContext(), "Please check your input.", Toast.LENGTH_SHORT).show();
}
Hope this helps. Write if you have any problems.

Categories

Resources