我想练习祈祷时间,所有的代码都是正确的,但结果是错误的,可能是鼻窦有问题.日落和日出时间公式和中午的太阳是高峰时间公式可能是错误的.

public void onLocationChanged(Location loc) {
    GPSEnlem = loc.getLatitude();
    GPSBoylam = loc.getLongitude();

    String Text = "Bulunduğunuz konum bilgileri : \n" + "Latitud = " + loc.getLatitude() + "\nLongitud = " + loc.getLongitude();
    konumText.setText(Text);

    String pattern = "dd_MM_yyyy";
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
    String date = simpleDateFormat.format(new Date());

    String day = date.substring(0, 1);
    String month = date.substring(3, 4);
    String year = date.substring(6, 9);

    double dayy = Double.valueOf(day);
    double monthh = Double.valueOf(month);
    double yearr = Double.valueOf(year);

    double I = yearr;
    double J = monthh;
    double K = dayy;

    double jd = 665176 + (1461 * (I + 4800 + (J - 14) / 12)) / 4 + (367 * (J - 2 - 12 * ((J - 14) / 12))) / 12 - (3 * ((I + 4900 + (J - 14) / 12) / 100)) / 4 + K - 32075;

    double d = jd - 2451545; // jd verilen Jülyen tarihidir

    double g = 357.529 + 0.98560028 * d;
    double q = 280.459 + 0.98564736 * d;
    double L = q + 1.915 * sin(Math.toRadians(g)) + 0.020 * sin(Math.toRadians(2 * g));

    double R = 1.00014 - 0.01671 * cos(Math.toRadians(g)) - 0.00014 * cos(Math.toRadians(2 * g));
    double e = 23.439 - 0.00000036 * d;
    double RA = atan2(cos(Math.toRadians(e)) * sin(Math.toRadians(L)), cos(Math.toRadians(L))) / 15;

    double D = asin(sin(Math.toRadians(e)) * sin(Math.toRadians(L))); // Güneş'in sapması
    double EqT = q / 15 - RA; // zaman denklemi

    double Lng = 30.0;
    double Ltd = 39.0;
    double SaatDilimi = 3;
    double oglevakti = 12.0 + SaatDilimi - (Lng / 15.0) - EqT;
    double a = 0;

    double n = d;
    double Jk = n - (Lng / 360.0);
    double M = (357.5291 + 0.98560028 * Jk) % 360.0;

    double C = 1.9148 * sin(M) + 0.0200 * sin(2.0 * M) + 0.0003 * sin(3.0 * M);

    double lambda = (M + C + 180 + 102.9372) % 360.0;

    double si = asin(sin(lambda) * sin(23.4397));

    double Ta = (acos(-sin(a) - sin(Ltd) * sin(si))) / 15.0;

    double T0833 = acos(-sin(0.833) - sin(GPSEnlem) * sin(si)) / 15.0;

    double T17 = acos(Math.toRadians(-sin(17) - sin(GPSEnlem) * sin(si))) / 15.0;

    double T18 = acos(Math.toRadians(-sin(18) - sin(GPSEnlem) * sin(si))) / 15.0;

    double gunesvakti = oglevakti - T0833;
    double aksamvakti = oglevakti + T0833;
    double imsakvakti = oglevakti - T18;
    double yatsivakti = oglevakti + T17;
    double AL = 2 + abs(tan(GPSEnlem) - si);
    double A2 = 1 / AL;
    double ikindivakti = oglevakti + A2;
}

推荐答案

您提取年、月、日的代码错误.

一件事是,substring()返回从beginIndexendIndex-1的字符,这意味着

String day = date.substring(0, 1);

只返回当天的第一个字符.正确的用法应该是

String day = date.substring(0, 2);
String month = date.substring(3, 5);
String year = date.substring(6, 10);

但整个代码都不必要地令人费解.您应该忽略java.util.Date类,而使用java.time包中更好的类:

LocalDate today = LocalDate.now();
int day = today.getDayOfMonth();
int month = today.getMonthValue();
int year = today.getYear();

Java相关问答推荐

当耗时的代码完成时,Circular ProgressIndicator显示得太晚

Annotation @ Memphier无法正常工作,并表示:class需要一个bean,但找到了2个bean:

当切换javaFX场景时,stage的大小正在Minimize

Spring boot:Bean和动态扩展器

了解Android Studio中的调试器输出

为什么Java的代码工作(if condition内部的实例)

给定Java枚举类,通过值查找枚举

如何正确创建序列图?

由于 list 中的权限错误,Android未生成

如何在Application.yaml中连接字符串?

使用OAuth 2.0资源服务器JWT时的授权(授权)问题

MimeMessage emlMessage=new MimeMessage(Session,emlInputStream);抛出InvocationTargetException

如何在Cosmos DB(Java SDK)中增加默认响应大小

在JDK Flight Recorder中只记录单个线程

协同 routine 似乎并不比JVM线程占用更少的资源

JavaFX,GridPane:在GridPane的列中生成元素将保持所有列的宽度

Java中的一个错误';s stdlib SocksSocketImpl?

如何通过gradle命令行从build.gradle获得Java targetCompatibility

始终使用Spring Boot连接mongodb上的测试数据库

为什么child-pom会创建一个新版本