All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nmote.iim4j.serialize.DateSerializer Maven / Gradle / Ivy

Go to download

IIM4J allows Java programmers to read, write and process IPTC IIM version 4 files.

The newest version!
/*
 * Copyright (c) Nmote Ltd. 2004-2015. All rights reserved.
 * See LICENSE doc in a root of project folder for additional information.
 */

package com.nmote.iim4j.serialize;

import java.io.UnsupportedEncodingException;

/**
 * Serializer for dates.
 */
public class DateSerializer implements Serializer {

	public DateSerializer(String format) {
		this.format = format;
	}

	public Object deserialize(byte[] data, SerializationContext ctx) throws SerializationException {
		try {
			return new String(data, "ISO-8859-1");
		} catch (UnsupportedEncodingException e) {
			throw new SerializationException("impossible");
		}
	}

	public byte[] serialize(Object o, SerializationContext ctx) throws SerializationException {
		try {
			return ((String) o).getBytes("ISO-8859-1");
		} catch (UnsupportedEncodingException e) {
			throw new SerializationException("impossible");
		}
	}

	public String toString() {
		return format;
	}

	private final String format;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy