Java Date Format Change convertDateFormatByRawOffset(DateFormat formatter, int rawOffset, long milliSecond)

Here you can find the source of convertDateFormatByRawOffset(DateFormat formatter, int rawOffset, long milliSecond)

Description

convert Date Format By Raw Offset

License

Open Source License

Declaration

public static String convertDateFormatByRawOffset(DateFormat formatter, int rawOffset, long milliSecond) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.DateFormat;

import java.util.Date;
import java.util.TimeZone;

public class Main {
    public static String convertDateFormatByRawOffset(DateFormat formatter, int rawOffset, long milliSecond) {
        TimeZone destTZ = TimeZone.getDefault();
        String[] timeZoneIds = TimeZone.getAvailableIDs(rawOffset);
        if (timeZoneIds != null && timeZoneIds.length > 0) {
            destTZ = TimeZone.getTimeZone(timeZoneIds[0]);
            formatter.setTimeZone(destTZ);
        } else {//from   ww  w  .j a  v a2  s . co m
            formatter.setTimeZone(destTZ);
        }

        return formatter.format(new Date(milliSecond));
    }
}

Related

  1. convertDate(String inPattern, String outPattern, String date)
  2. convertDate(String str)
  3. convertDate(String value)
  4. convertDateFormat(String date, SimpleDateFormat formatBefore, SimpleDateFormat formatAfter)
  5. convertDateFormat(String sourceDate, String sourceDateFormat, String destDateFormat)
  6. convertDateFromInDayFormat(String stringDate, String hhmmss)
  7. convertDateFromTo(String stringDate, String patternToUse, TimeZone timezoneIn, TimeZone timezoneOut)
  8. convertDateStringToString(String dateString, String format)
  9. convertDateStringToString(String strDate, String currentFormat, String parseFormat)