I have a code that displays time in GMT and I need to show it in PST. How can I modify the below code to get the time in PST?
Code
public static final String FORMAT = "MM/dd/yyyy";
public static final String OUTPUT_FORMAT_STD_DATE6 = "MM/dd/yy hh:mm a";
public static final String INPUT_FORMAT_STD_TIMESTAMP = "yyyy-MM-dd HH:mm:ss";
public static String formatDate(String strDate, String inputFormat, String outputFormat) {
Date date = convertStringToDate(strDate,inputFormat);
String displayDateString = formatDate(date, outputFormat);
return displayDateString;
}
formatDate is being called here
public void endElement(String uri, String localName, String qName) throws SAXException {
if( EVENT.equalsIgnoreCase( qName ) ) {
auditEntries.add(entry);
} else if( LOG_TIME.equalsIgnoreCase( qName ) ) {
String time = content.toString();
entry.setLogTime( DateUtils.formatDate(time, "yyyy-MM-dd'T'HH:mm:ss", DateUtils.OUTPUT_FORMAT_STD_DATE6));
}
Please help, I am new b in writing Java code.
This is how I am doing it.
public static String formatDate(String strDate, String inputFormat, String outputFormat) {
Date date = convertStringToDate(strDate,inputFormat);
DateFormat pstFormat = new SimpleDateFormat( outputFormat );
pstFormat.setTimeZone( TimeZone.getDefault() );
String displayDateString = formatDate(date, outputFormat);
return displayDateString;
}
Thanks