How to format date without year using Simple Date Format?
There is the following code:
public static String getDateOnCurrentTimezone(String date, String timezone) {
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd kk:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone(timezone));
try {
Date d = sdf.parse(date);
sdf.setTimeZone(TimeZone.getDefault());
return sdf.format(d);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
This code must format date from one timezone to other one without date,
but it returns "null" always. If I change format to "yyyy-MM-dd" it works
good. How can I fix it? Thanks.
No comments:
Post a Comment