简体   繁体   中英

Cannot resolve method setToNow() on Android Studio

I am getting an error Cannot resolve method setToNow() , getJulianDay on Android Studio. I think i have imported the correct Classes.

在此处输入图片说明

Imports

import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.sql.Time;
import java.text.SimpleDateFormat;

Time dayTime = new Time();
dayTime.setToNow();
int julianStartDay = Time.getJulianDay(System.currentTimeMillis(), dayTime.gmtoff);

There is no setToNow() in java.sql.Time you need to use android.text.format.Time .

But be careful because it is deprecated

http://developer.android.com/reference/android/text/format/Time.html

This class was deprecated in API level 22. Use GregorianCalendar instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM