بروز خطا
   [message]
اشتراک در سوال
رای ها
[dataList]
پرسش و پاسخ

مشکل در گرفتن تاریخ شمسی از اینترنت؟

مدیریت گفتگو
imanbenoit 12 سال پیش
آخرین تغییر: 12 سال پیش

سلام  خسته نباشید

برای پیدا کردن  تاریخ  میلادی   توی سایت  Stack overflow  من این کد رو پیدا کردم که جواب هم میده   

  public String getTime() {
        try {
            //Make the Http connection so we can retrieve the time
            HttpClient httpclient = new DefaultHttpClient();
            // I am using yahoos api to get the time
             HttpResponse resp
                    HttpGet("http://developer.yahooapis.com/TimeService/V1/getTime?appid=YahooDemo"));
            StatusLine statusLine = response.getStatusLine();
            if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                response.getEntity().writeTo(out);
                out.close();
                // The response is an xml file and i have stored it in a string
                 String resp
                Log.d("Response", responseString);
                //We have to parse the xml file using any parser, but since i have to 
                //take just one value i have deviced a shortcut to retrieve it
                int x = responseString.indexOf("");
                int y = responseString.indexOf("");
                //I am using the x + "" because x alone gives only the start value
                Log.d("Response", responseString.substring(x + "".length(), y));
                String timestamp = responseString.substring(x + "".length(), y);
                // The time returned is in UNIX format so i need to multiply it by 1000 to use it
                Date d = new Date(Long.parseLong(timestamp) * 1000);
                Log.d("Response", d.toString());
                return d.toString();
            } else {
                //Closes the connection.
                response.getEntity().getContent().close();
                throw new IOException(statusLine.getReasonPhrase());
            }
        }
        catch (ClientProtocolException e) {
            Log.d("Response", e.getMessage());
        }
        catch (IOException e) {
            Log.d("Response", e.getMessage());
        }
        return null;
    }

 

سوال  اینجاست برای   تاریخ شمسی باید چیکار کنیم؟؟؟

من  یکسری  پارامتر ها یا  مسیر های رو پیدا کردم  مثلا دوتا سایت پایین رو ببینید ولی بلد نیستم  توی برنامه ازشون استفاده ببرم :

نمونه آدرس اول

 نمونه ادرس دوم

نظرات

پاسخ‌ها 2

OmidAhmadian 12 سال پیش

نیازی به گرفتن ادرس شمسی از اینترنت نیست،کتابخونه های زیادی برای جاوا نوشته شده که تاریخ میلادی رو می گیره و تاریخه شمسی و قمری رو تحویل میده،تاریخ میلادی رو از خوده گوشی بگیر با استفاده از این کتابخانه ها اونو به تاریخه شمسی تبدیل کن

این اسمو توی github سرچ کن یه تقویمه شمسیه ببین مبدله میلادی به شمسیشو می تونی استفاده کنی یا نه
DroidPersianCalendar

نظرات

imanbenoit 12 سال پیش
نمونه کد ندارین؟
imanbenoit 12 سال پیش

نظرات

imanbenoit 12 سال پیش
چرا سورس کدم رو نمیتونم ببینم مهندسسسسسسسسسسسسسسسسسسسسسسسس!!

پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .