is there simple method to get hijri date as DateTime? [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I found answer to hijri date in Islamic calendar but the code is very complex.
The Question
is there simple function to get it as DateTime type ?

Try using the Joda-Time API IslamicChronology. It's not part of the Android API, download the JAR and add it to your build path to use it in Android projects.
See Joda-Time documentation for Islamic calendar system.
Example code taken from that documentation:
// setup date object for midday on May Day 2004 (ISO year 2004)
DateTime dtISO = new DateTime(2004, 5, 1, 12, 0, 0, 0);
// find out what the same instant is using the Islamic Chronology
DateTime dtIslamic = dtISO.withChronology(IslamicChronology.getInstance());

Related

How to get date and time in below format in java? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
How can I get the current date and time and how can I transfer it into the following String format?
06-04-2020 05:00 PM
After that I need to add few minutes to the date? Please help!
Your answer should look something like this:
String dateTimePattern = "dd-MM-yyyy HH:mm a";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateTimePattern );
LocalDateTime yourDay= LocalDateTime.of(2020, 4, 6, 17, 00);
System.out.println(formatter.format(ZonedDateTime.of(yourDay, ZoneId.of("UTC-5"))));
Please look this up for more info on the available formats.
Date yourDate = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy h:m a");
String formatedDate= sdf.format(yourDate);

Joda time local zone to utc conversion [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
I am trying gmt asia/kolkata timemillis convert to utc timemillis but it returns same value. Environment time is asia/kolkata
The epoch is time zone independent. So you should get the same number of milliseconds since the epoch back no matter which time zone you convert to.
So the result you got is correct.
You can try as this
Instant date = Instant.ofEpochMilli(1549362600000l);
LocalDateTime utc = LocalDateTime.ofInstant(date, ZoneOffset.UTC);
You need not to use Joda time api has moved to java 1.8 has implemented the same you can use above same from java.time package

Adding days to current date in java [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I just want to add the 3 days to the current date and print the new date in hive query using java..
please help me out
Calendar c = Calendar.getInstance();
c.setTime(new Date());
c.add(Calendar.DATE, 3);

Regex for SimpleDateFormat string [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have dates mainly in the forms of yyyy-MM-dd and yyyy-MM-dd hh:mm:ss. I want to pattern match yyyy-MM-dd hh:mm:ss.
Is it trivial to write an regex for this purpose? I am new to regex so would appreciate any resource tat could get me up to speed?
If you are trying to find these date notations in a String, then regexes is indeed a good choice. You could use this regex:
\b\d{4}-\d{2}-\d{2} \d{1,2}:\d{2}:\d{2}\b
See it in action here: http://rubular.com/r/qZOTsUikbo. Note: this matches "dates" like
9999-99-99 99:99:99 as well. If that is a problem for you, you could verify them after you found the potential Strings.
If you want to parse them, then use a SimpleDateFormat.
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date date = sdf.parse("2013-12-24 18:31:20");
You don't need to write reg expression for it.
Java already has support for it. Here is the link to follow.
http://developer.android.com/reference/java/text/SimpleDateFormat.html

How to get whole Week Date From the Selected Date in Java [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
i want to have FirstDay of week and last Day of week into the Date Format means i need whole Week date in java using DateChooser means i need to have that whole Existing week for that date. show how to get it i trying to have that logic.
Please Help me and thank you in advance for your Response..
You can use the Calendar class.
Calendar cal = Calendar.getInstance ();
int dayofWeek = cal.get (Calendar.DAY_OF_WEEK);
cal.add (Calendar.DATE, -1 * (dayofWeek - Calendar.MONDAY));
Date fdow = cal.getTime ();
As the cal object is now modified, just add six to get the last day of the week.
cal.add (Calendar.DATE, 6);
Date ldow = cal.getTime ();
Using the third-party Joda-Time makes it a bit easier.
See the question Get first day of a particular week in Joda-Time? java.

Categories

Resources