converting gregorian to hijri date

Firstly, separate out the conversion part from the formatting/parsing part. You can deal with those easily later – and there are lots of questions on Stack Overflow about that. Personally I’d use Joda Time, which typically makes life much simpler. For example: import org.joda.time.Chronology; import org.joda.time.LocalDate; import org.joda.time.chrono.IslamicChronology; import org.joda.time.chrono.ISOChronology; public class Test { public … Read more

Converting date in Year.decimal form in R

The lubridate package has a function, date_decimal that you can use for this. x <- c(1988.0, 1988.25, 1988.5, 1988.75) library(lubridate) (f <- format(date_decimal(x), “%d-%m-%Y”)) # [1] “01-01-1988” “01-04-1988” “02-07-1988” “01-10-1988” Then you can write it to a csv with write.csv(f, “afilename.csv”) ## or write.table() You’ll probably want to check the output first and adjust some … Read more

Date and time conversion to some other Timezone in java

It’s over the web. Could have googled. Anyways, here is a version for you (shamelessly picked and modified from here): Calendar calendar = Calendar.getInstance(); TimeZone fromTimeZone = calendar.getTimeZone(); TimeZone toTimeZone = TimeZone.getTimeZone(“CST”); calendar.setTimeZone(fromTimeZone); calendar.add(Calendar.MILLISECOND, fromTimeZone.getRawOffset() * -1); if (fromTimeZone.inDaylightTime(calendar.getTime())) { calendar.add(Calendar.MILLISECOND, calendar.getTimeZone().getDSTSavings() * -1); } calendar.add(Calendar.MILLISECOND, toTimeZone.getRawOffset()); if (toTimeZone.inDaylightTime(calendar.getTime())) { calendar.add(Calendar.MILLISECOND, toTimeZone.getDSTSavings()); } System.out.println(calendar.getTime());