How to Convert Time Zone to UTC time zone using jorda time

java android

84 观看


110 作者的声誉

Using this code

String twelveHourTime="06:00 PM";

public static DateTime convert12HourTimeTo24HourTime(String twelveHourTime) {
        DateTimeFormatter dateTimeFormatter =
        DateTime dateTime = dateTimeFormatter.parseDateTime(twelveHourTime);
        return  new DateTime().withHourOfDay(dateTime.getHourOfDay())

I am getting this date time:

String datetime=2017-09-15T18:00:23.153+05:30

Now I want to convert it to the US time zone.

Please suggest me how to do this.

作者: Adevelopment 的来源 发布者: 2017 年 9 月 15 日

回应 3


0 作者的声誉

Use localDateTime:

DateTime dt = new LocalDateTime(timestamp.getTime()).toDateTime(DateTimeZone.UTC);
作者: user3906011 发布者: 2017 年 9 月 15 日


1581 作者的声誉

you can use it by using TimeZone and SimpleDateFormat :-

            TimeZone time = TimeZone.getTimeZone("UTC");
            Calendar cal = Calendar.getInstance(time);
            final Date startDate = cal.getTime();
            SimpleDateFormat sdfAmerica = new SimpleDateFormat("dd-M-yyyy hh:mm:ss a");
            String sDateInAmerica = sdfAmerica.format(startDate);

作者: Shubham Sejpal 发布者: 2017 年 9 月 15 日


63 作者的声誉

You can use SimpleDateFormat for conversion

  DateFormat df = new SimpleDateFormat("dd/MM/yyyy HH24:MI");
  Date date = df.parse(datetime);
作者: UMKalaycı 发布者: 2017 年 9 月 15 日